[wp-trac] [WordPress Trac] #38906: wp_get_attachment_image_src() sometimes gives incorrect width and height values

WordPress Trac noreply at wordpress.org
Wed Dec 21 20:05:14 UTC 2022


#38906: wp_get_attachment_image_src() sometimes gives incorrect width and height
values
-------------------------------------+-----------------------------
 Reporter:  pressupinc               |       Owner:  (none)
     Type:  defect (bug)             |      Status:  reopened
 Priority:  normal                   |   Milestone:  Future Release
Component:  Media                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch 2nd-opinion  |     Focuses:  administration
-------------------------------------+-----------------------------
Changes (by azaozz):

 * keywords:   => needs-patch 2nd-opinion


Comment:

 Replying to [comment:16 desrosj]:
 > While I don't disagree that this is likely not truly a bug (listing the
 size the image will be inserted into the editor at is reasonable), I do
 think it's quite confusing.

 Yes, it is confusing. This is a UI problem. Thinking that the preferred
 fix here is to remove the pixel dimensions from the "Size" drop-down, and
 only leave the "Thumbnail", "Medium", "Large" sizes. The reason is that
 the pixel sizes give the wrong impression that the selected sub-size will
 be used or that it matters at all. In reality the browser will determine
 which size to use from the sizes listed in the `srcset` attribute.

 Also thinking that the two custom sizes named "1536x1536" and "2048x2048"
 don't belong there. They are virtually unusable in the editor and were
 added to satisfy the `srcset` requirements for high-res displays.

 > I'd also like to know, does this only surface in "classic" editing
 contexts? Is this still present when inserting images using the
 image/media blocks?

 Only in the classic editor. When selecting an image for the image block,
 or other blocks that support images, the "Large" size is always used. The
 user can select to constrain the image dimensions in different ways
 (dragging, selecting "Medium", etc.), but as mentioned above the browser
 makes the final decision of how the image will look and which file to
 load.

 > I'd love for the media team to have the chance to discuss this a bit
 more before closing out.

 Yea, thinking it would be best to resolve this ticket together with #34225
 and #35390 at the same time. Ideally the resolution would to fix the UI
 (removing pixel dimensions), and deprecate
 `image_constrain_size_for_editor()` which is being misused a lot by themes
 (was supposed to be only for images displayed in the old editor...).

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


More information about the wp-trac mailing list