The Pilcrow

A WordPress developer's thoughts on professional and personal development. Written by Karin Taliga

Responsive images are coming to WordPress core

I while back, I wrote about an awesome plugin that adds support in WordPress for reponsive image markup. Specifically, it outputs the srcset and sizes attributes to the image tags. The browser can then decide which image size it will request from the server.

Well the good news is – the plugin has been slated to merge into core!

In 4.4, planned to be released in December this year, one of the features is support for responsive images. WP-tavern did an interview with Joe McGill where he explains a bit more of how this works.

What does it mean for you?

As a theme developer, any image sizes that you define yourself will be included in the srcset attribute. Check your images in different devices and screen sizes (but of course you already do this). There will be several new filters available to control the output of both the srcset and sizes attributes. You might need to make use of them in order to make the responsive images behave as you wish.

Since WordPress 4.4 still is in beta, things might change in the details. I will revisit this topic when the release is ready and write about these new filters and how to use them.

Also, core is not bundling any polyfill for browsers that doesn’t understand these new html5 attributes. At this point in time, the developers recommends using something like Picturefill to help those browsers along.

As a website owner, the best part is that you don’t have do to anything at all. Nothing has changed for the user, only the code output in the backend is different.

As a visitor to your site, the images you see will depend on the browser you are using. If you are browsing on a mobile device, a smaller image will be requested and shown to you. This means faster pageload and snappier sites. It might even save a bit of money on your data plan depending on how many sites that benefit by this change!

It’s a win-win situation, and one of the features I am happy to see going into core.

 

Next Post

Previous Post

© 2017 The Pilcrow

Theme by Anders Norén