[wp-trac] [WordPress Trac] #35106: Responsive images break uploads will full path stored in metadata

WordPress Trac noreply at wordpress.org
Tue Dec 15 20:46:43 UTC 2015


#35106: Responsive images break uploads will full path stored in metadata
----------------------------+--------------------------------------
 Reporter:  SergeyBiryukov  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  4.4.1
Component:  Media           |    Version:  4.4
 Severity:  normal          |   Keywords:  has-patch has-unit-tests
  Focuses:                  |
----------------------------+--------------------------------------
 Before [8796], we used to store absolute file paths for uploaded images.

 On my install, I have a couple files uploaded in a pre-2.7 era, where
 `_wp_attached_file` looks like this: `H:\home\wordpress\trunk/wp-
 content/uploads/2008/06/2429111678_2ecb3abb93_b.jpg`.

 They used to display correctly before 4.4, but now the following markup is
 generated:

 `<img width="1024" height="755" src="http://trunk.wordpress/wp-
 content/uploads/2008/06/2429111678_2ecb3abb93_b.jpg" class="attachment-
 post-thumbnail size-post-thumbnail wp-post-image" alt="Sticky"
 srcset="http://trunk.wordpress/wp-content/uploads/H:\home\wordpress\trunk
 /wp-content/uploads/2008/06/2429111678_2ecb3abb93_b-300x221.jpg 300w,
 http://trunk.wordpress/wp-content/uploads/H:\home\wordpress\trunk/wp-
 content/uploads/2008/06/2429111678_2ecb3abb93_b.jpg 1024w" sizes="(max-
 width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw,
 (max-width: 1362px) 62vw, 840px">`

 The culprit is [source:tags/4.4/src/wp-includes/media.php?marks=1009#L989
 wp_calculate_image_srcset()], which assumes that `dirname(
 $image_meta['file'] )` is always relative.

 We could borrow the fix from [source:tags/4.4/src/wp-
 includes/post.php?marks=4872#L4854 wp_get_attachment_url()], where it was
 added in [10254].

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


More information about the wp-trac mailing list