[wp-trac] [WordPress Trac] #34532: Responsive images: calculate the image baseurl from the original image `src`.

WordPress Trac noreply at wordpress.org
Mon Nov 2 23:40:46 UTC 2015


#34532: Responsive images: calculate the image baseurl from the original image
`src`.
--------------------------+--------------------
 Reporter:  azaozz        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.4
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+--------------------

Comment (by azaozz):

 > ...it's possible that we could add invalid urls to the srcset attribute.
 The browser has no way of knowing if a source is valid or not during the
 selection process, which could result in broken images.

 Right. It even looks like the browsers completely ignore the `src`
 attribute and switch to using only `srcset`. Images with correct `src` but
 wrong URLs in `srcset` show as broken in both Firefox and Chrome, no
 matter the size/page width.

 > ...we're making the assumption that because one image size is stored in
 a specific places that all other sizes of that same image are also stored
 there.

 I've been having the same thoughts/concerns. Even when using
 `wp_upload_dir()` we are still making the same assumption. There is no
 context when this function runs or the filter is applied, so if different
 image sub-sizes are in different locations, we will still be generating
 wrong URLs. I'm not even sure if it is possible to have different image
 sub-sizes in different locations and still be able to insert them in the
 editor (using the media modal).

 On the other hand using `wp_upload_dir()` may be "safer" for older posts
 on sites that have been moved to a new server, or have started using a
 CDN. It will get all the updated options and can be filtered by plugins
 and themes.

 In that terms thinking it's best to make a patch with the other
 updates/fixes for #34430, but continue to use wp_upload_dir().

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


More information about the wp-trac mailing list