Skip to content

Commit

Permalink
DataViews: Correctly display featured image that don't have image siz…
Browse files Browse the repository at this point in the history
…es (#59111)

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: colorful-tones <[email protected]>
Co-authored-by: annezazu <[email protected]>
  • Loading branch information
6 people authored and youknowriad committed Feb 20, 2024
1 parent 4060148 commit 6b4189c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/edit-site/src/components/media/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ function Media( { id, size = [ 'large', 'medium', 'thumbnail' ], ...props } ) {
const currentSize = size.find(
( s ) => !! media?.media_details?.sizes[ s ]
);
const mediaDetails = media?.media_details?.sizes[ currentSize ];
if ( ! mediaDetails ) {

const mediaUrl =
media?.media_details?.sizes[ currentSize ]?.source_url ||
media?.source_url;

if ( ! mediaUrl ) {
return null;
}

return (
<img
{ ...props }
src={ mediaDetails.source_url }
alt={ media.alt_text }
/>
);
return <img { ...props } src={ mediaUrl } alt={ media.alt_text } />;
}

export default Media;

0 comments on commit 6b4189c

Please sign in to comment.