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 getdave committed Feb 20, 2024
1 parent 7b589f9 commit a2f73e6
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 a2f73e6

Please sign in to comment.