[wp-trac] [WordPress Trac] #55247: SVG logos generate warnings from _wp_get_image_size_from_meta()

WordPress Trac noreply at wordpress.org
Thu Feb 24 12:50:48 UTC 2022


#55247: SVG logos generate warnings from _wp_get_image_size_from_meta()
--------------------------+-----------------------------
 Reporter:  gillespieza   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  5.9
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 If I set an SVG image as my logo in the customizer, my debug log gets
 filled with the following notices:

 ``` PHP Notice:  Trying to access array offset on value of type bool in
 /{redacted}/wp-includes/media.php on line 1182 ```

 Looking at that file, that section refers to the following function:

 {{{#!php
 <?php
 function _wp_get_image_size_from_meta( $size_name, $image_meta ) {
         if ( 'full' === $size_name ) {
                 return array(
                         absint( $image_meta['width'] ),
                         absint( $image_meta['height'] ),
                 );
         } elseif ( ! empty( $image_meta['sizes'][ $size_name ] ) ) {
                 return array(
                         absint( $image_meta['sizes'][ $size_name
 ]['width'] ),
                         absint( $image_meta['sizes'][ $size_name
 ]['height'] ),
                 );
         }

         return false;
 }
 }}}


 I suspect what's happening here is the function is assuming there will
 always be a height and width meta, which doesn't exist with SVG file
 types.

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


More information about the wp-trac mailing list