[wp-trac] [WordPress Trac] #64480: WordPress PHP Deprecated: Implicit conversion from float 44.168

WordPress Trac noreply at wordpress.org
Thu Jan 8 21:18:54 UTC 2026


#64480: WordPress PHP Deprecated: Implicit conversion from float 44.168
-------------------------------+------------------------------
 Reporter:  sotnas             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Media              |     Version:  6.9
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by Presskopp):

 I assume the error comes from this block of code:


 {{{
 // The 'src' image has to be the first in the 'srcset', because of a bug
 in iOS8. See #35030.
         if ( $is_src ) {
                 $sources = array( $image['width'] => $source ) + $sources;
         } else {
                 $sources[ $image['width'] ] = $source;
         }
 }}}

 Since {{{$image['width']}}} is used as an array key, an implicit float-to-
 int conversion can occur under PHP 8.1.
 Casting the value explicitly beforehand should resolve the warning:

 {{{$width = (int) $image['width'];}}}

 and then using {{{$width}}} as the array key.

 That said, the open question is why {{{$image['width']}}} can be a float
 in the first place, given that image dimensions are generally expected to
 be integers.

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


More information about the wp-trac mailing list