[wp-trac] [WordPress Trac] #36239: wp-embed image size is using the smallest image or it sometimes uses the one for featured images

WordPress Trac noreply at wordpress.org
Fri Sep 25 19:44:53 UTC 2020


#36239: wp-embed image size is using the smallest image or it sometimes uses the
one for featured images
-----------------------------------+------------------------------
 Reporter:  carasmo                |       Owner:  (none)
     Type:  defect (bug)           |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Embeds                 |     Version:  4.4.2
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------
Changes (by desrosj):

 * keywords:   => has-patch 2nd-opinion
 * milestone:   => Awaiting Review


Comment:

 > I was keeping the image sizes generated by media to very teeny

 I think this would be OK to close out as being caused by a weird
 configuration of image sizes.

 Looking at the underlying code, we could enforce a
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/theme-
 compat/embed-content.php#L34 minimum dimension check for the login within]
 `embed-content.php`. The `foreach` loop there iterates through each
 generated image size for the specified thumbnail, but it only checks that
 the height is greater than 0 and that the aspect ratio is greater than 1
 (or greater than the last image size that passed the conditional).

 As far as I can tell, image meta data is not sorted into any specific
 order before it's saved in meta. It's based mostly of the order the image
 sizes are registered/stored in the `$_wp_additional_image_sizes` global,
 or when [https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/includes/image.php?rev=49021#L141 missing sub-sizes are back-filled
 (after 5.3)]. So there's no guarantee the last matched image size is the
 largest, or even large enough to be worth displaying.

 [attachment:"36239.diff"] enforces a minimum width/height requirement of
 150px (the default for the Core thumbnail size) to prevent an image that's
 "too small" from showing. I debated using 300 as the base, but that could
 potentially limit the number of posts that show an image within an embed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/36239#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list