[wp-trac] [WordPress Trac] #47713: image_get_intermediate_size does not return size if it equals original size

WordPress Trac noreply at wordpress.org
Sat Sep 5 19:39:17 UTC 2020


#47713: image_get_intermediate_size does not return size if it equals original size
----------------------------------------+-----------------------------
 Reporter:  mahnunchik                  |       Owner:  SergeyBiryukov
     Type:  defect (bug)                |      Status:  reviewing
 Priority:  normal                      |   Milestone:  Future Release
Component:  Media                       |     Version:  5.2.2
 Severity:  major                       |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+-----------------------------

Comment (by Mista-Flo):

 I tried with your image, renamed it test-2000x1200.jpg

 {{{#!php
 <?php
                 add_image_size( 'test-size', 2000, 1200, true );

                 $file = DIR_TESTDATA . '/images/test-2000x1200.jpg';
                 $id   = $this->_make_attachment( $file, 0 );

                 // Look for a size by name.
                 $image = image_get_intermediate_size( $id, 'test-size' );
                 var_dump( $image );

                 $image = image_get_intermediate_size( $id, [2000, 1200] );
                 var_dump( $image );
 }}}

 Here's my var_dump output


 {{{
 array(6) {
   ["file"]=>
   string(30) "test-2000x1200-1-2000x1200.jpg"
   ["width"]=>
   int(2000)
   ["height"]=>
   int(1200)
   ["mime-type"]=>
   string(10) "image/jpeg"
   ["path"]=>
   string(38) "2020/09/test-2000x1200-1-2000x1200.jpg"
   ["url"]=>
   string(76) "http://example.org/wp-content/uploads/2020/09/test-
 2000x1200-1-2000x1200.jpg"
 }
 array(6) {
   ["file"]=>
   string(30) "test-2000x1200-1-2000x1200.jpg"
   ["width"]=>
   int(2000)
   ["height"]=>
   int(1200)
   ["mime-type"]=>
   string(10) "image/jpeg"
   ["path"]=>
   string(38) "2020/09/test-2000x1200-1-2000x1200.jpg"
   ["url"]=>
   string(76) "http://example.org/wp-content/uploads/2020/09/test-
 2000x1200-1-2000x1200.jpg"
 }

 }}}

 What's wrong with my test please, I don't get it.

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


More information about the wp-trac mailing list