Skip to content

Commit

Permalink
Check if thumbnail_url is set in getPhotoHtml (#13825)
Browse files Browse the repository at this point in the history
thumbnail_url is an optional field in oembed endpoints. Check it is set first before using and fallback to url if not.
  • Loading branch information
spacedmonkey authored and youknowriad committed Mar 6, 2019
1 parent 5808c15 commit bee0424
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/block-library/src/embed/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export const isFromWordPress = ( html ) => {

export const getPhotoHtml = ( photo ) => {
// 100% width for the preview so it fits nicely into the document, some "thumbnails" are
// actually the full size photo.
const photoPreview = <p><img src={ photo.thumbnail_url } alt={ photo.title } width="100%" /></p>;
// actually the full size photo. If thumbnails not found, use full image.
const imageUrl = ( photo.thumbnail_url ) ? photo.thumbnail_url : photo.url;
const photoPreview = <p><img src={ imageUrl } alt={ photo.title } width="100%" /></p>;
return renderToString( photoPreview );
};

Expand Down

0 comments on commit bee0424

Please sign in to comment.