Skip to content

Commit

Permalink
Media & Text block: Remove the link option when the featured image is…
Browse files Browse the repository at this point in the history
… used (#60510)

* Media & Text block: Remove the link option when the featured image is used.

When the Media & Text block uses the featured image and the link option, the block outputs invalid HTML.
This change resolves the invalid markup on the front, by preventing users from adding the link using the toolbar option.

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
  • Loading branch information
8 people authored May 31, 2024
1 parent cc7dbab commit 8f74fcb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ function MediaTextEdit( {
mediaId: undefined,
mediaUrl: undefined,
mediaAlt: undefined,
mediaLink: undefined,
linkDestination: undefined,
linkTarget: undefined,
linkClass: undefined,
rel: undefined,
href: undefined,
useFeaturedImage: ! useFeaturedImage,
} );
};
Expand Down Expand Up @@ -453,17 +459,13 @@ function MediaTextEdit( {
</>
) }

{ mediaType === 'image' && (
{ mediaType === 'image' && ! useFeaturedImage && (
<ImageURLInputUI
url={ href || '' }
onChangeUrl={ onSetHref }
linkDestination={ linkDestination }
mediaType={ mediaType }
mediaUrl={
useFeaturedImage && featuredImageURL
? featuredImageURL
: image && image.source_url
}
mediaUrl={ image && image.source_url }
mediaLink={ image && image.link }
linkTarget={ linkTarget }
linkClass={ linkClass }
Expand Down

1 comment on commit 8f74fcb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 8f74fcb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9312297563
📝 Reported issues:

Please sign in to comment.