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 (WordPress#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 and carstingaxion committed Jun 4, 2024
1 parent 5c5a1d9 commit 4321025
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

0 comments on commit 4321025

Please sign in to comment.