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

WordPress Trac noreply at wordpress.org
Wed May 25 13:20:34 UTC 2022


#38906: wp_get_attachment_image_src() sometimes gives incorrect width and height
values
--------------------------+-----------------------------
 Reporter:  pressupinc    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  normal        |   Milestone:  Future Release
Component:  Media         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:  administration
--------------------------+-----------------------------

Comment (by antonvlasenko):

 Thank you for sharing the info, @pressupinc .
 I still believe this is not a bug.
 Why?
 1. The current theme limits the width of an image. It’s not a WordPress
 limitation. The `Understrap` theme sets the value of the `$content_width`
 variable to 640 pixels. The `Twenty Twelve` theme sets `$content_width` to
 be 625 pixels. You can verify it here: https://github.com/WordPress
 /wordpress-develop/blob/trunk/src/wp-
 content/themes/twentytwelve/functions.php#L29
 2. When you upload an image, WordPress will create images no wider than
 the value of the`$content_width` variable. As far as I understand, this is
 by design and is needed not to break the layout.
 3. To overcome this limitation, you can manually increase the value of the
 `$content_width` variable (at your own risk) and then re-upload the
 images.

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


More information about the wp-trac mailing list