[wp-trac] [WordPress Trac] #43930: Inaccurate width and height returned when using wp_get_attachment_image_src on the backend.

WordPress Trac noreply at wordpress.org
Wed May 2 14:56:44 UTC 2018


#43930: Inaccurate width and height returned when using wp_get_attachment_image_src
on the backend.
--------------------------+-----------------------------
 Reporter:  jwoolsch      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I'm using wp_get_attachment_image_src on the backend to do image
 validation for a custom image selector meta box. When the image is large
 enough for the requested image size the source of the original image is
 returned but the dimensions are smaller.

 This is my call:

 {{{#!php
 <?php
 wp_get_attachment_image_src($thumbnail_id, 'custom-image-size');
 }}}

 and return:


 {{{
 array(4) {
   [0]=>
   string(70) "http://localhost:8888/wp-content/uploads/2018/05/image.jpg"
   [1]=>
   int(400)
   [2]=>
   int(400)
   [3]=>
   bool(false)
 }
 }}}

 The actual image dimensions are 1200x1200.

 The image_constrain_size_for_editor call in the image_downsize function
 seems to be where the problem lies. I can comment out that line and it
 works as expected.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43930>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list