Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nosilver4u

    (@nosilver4u)

    The best solution is still the .htaccess rewrite rules. That said, I need to do more research on the srcset stuff. It works nicely when using the same fileformat and various sizes, but I’m not sure what browsers will do if an unsupported filetype is found. Some of the other solutions I’ve seen cause Firefox and IE to try and load the web version (which wastes bandwidth), and only then they fallback to the regular image.

    At any rate, I’ll do some testing with it and see if it is a viable option.

    Thread Starter Adam Radocz

    (@adamradocz)

    Thank you for the consideration.
    I gave you wrong link in the previous post.
    Here is a workaround: https://www.useragentman.com/blog/2015/01/14/using-webp-jpeg2000-jpegxr-apng-now-with-picturefill-and-modernizr

    While srcset is awesome und just made it into core with 4.4, its not the right technique for implementing different file formats; thats what <picture> (among others things) is for, see https://jakearchibald.com/2015/anatomy-of-responsive-images/#varying-on-type.

    Browsersupport: https://caniuse.com/#search=picture

    But the nice thing is: “…falls back to the <img> in other browsers.”

    So, a non-breaking improvment ??

    Therefore i really would like to see such a feature, e.g. taking the <img>-output from wordpress including srcset and sizes and converting it to <picture>.

    In my understanding something like this is possible:

    <picture>
      <source type="image/webp" srcset="snow-320.webp 320w, …" sizes="…">
      <source type="image/jpg" srcset="snow-320.jpg 320w, …" sizes="…">
      <img alt="Hut in the snow" src="snow.jpg">
    </picture>
    Plugin Author nosilver4u

    (@nosilver4u)

    The biggest concern I would have with that is theme support via css. If css rules have been applied to <img> elements, I have my doubts as to whether or not they have also been applied to the much newer <picture> elements. That is definitely a possibility down the road, but for now the methods employed by EWWW using js or .htaccess rewrite rules are preferable.

    One other new development in this area, is that Photon (from the Jetpack plugin) now supports WebP automatically. If .htaccess rules don’t work (or you’re already using Photon), you don’t have to do anything tricky. It just automatically swaps out your images for any browser that supports WebP.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using srcset rather than Alternative WebP Rewriting’ is closed to new replies.