[wp-trac] [WordPress Trac] #60480: preg_match() warning in wp_image_add_srcset_and_sizes() when image_meta['file'] is missing

WordPress Trac noreply at wordpress.org
Thu Jul 24 13:41:51 UTC 2025


#60480: preg_match() warning in wp_image_add_srcset_and_sizes() when
image_meta['file'] is missing
--------------------------+------------------------------
 Reporter:  shanemac10    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Import        |     Version:  6.4.3
 Severity:  major         |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by leedxw):

 This is just a note that may be of assistance to anyone investigating
 this.

 We've started seeing this error on some sites (that have been running for
 many years).

 The error comes from looking up PDFs... even though the PDFs aren't in
 <img> tags on the page.

 On investigating I found instances of the page content looking like:

 {{{
 <figure class="wp-block-image alignleft is-resized">
 <img src="https://www.example.com/wp-content/uploads/2019/09/logo.jpg"
   alt=""
   class="wp-image-888"
   style="width:69px;height:104px"/>
 </figure>
 }}}

 But attachment ID 888 is not the ID of the referenced image, but is the
 attachment ID of an unrelated PDF.

 I don't know the cause of this mismatch, it could have happened at any
 time in the last 15 years, but it's why we've started seeing warnings from
 wp_image_add_srcset_and_sizes().

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


More information about the wp-trac mailing list