Stefan Ledin

Responsify WP 1.6

Since Responsify WP (RWP) was published on this summer, I’ve released eight updates to the plugin. Most of them was minor bugfixes and improvments, but there has been a couple of larger updates. The latest one, version 1.6, is the largest and greatest.

It started as a simple helper class that generated Picturefill markup. Now it starts to feel like a mature WordPress plugin that handles it’s job well. I guess it’s a good sign that I enjoy using it myself.
Thanks to some helpful users of RWP, the most critical bugs was discovered and I was able to fix them.
Version 1.4 was the one released at 1.5 added the possibility to select the real picture element as markup pattern instead of the one using span tags.
In late september, a blog post suggesting the usage of the img element with srcset and sizes attributes instead of picture was published. The article was picked up by Chris Coyer, Brad Frost and all the others. It was seen a lot on Twitter.
I had been thinking about implementing support for srcset/sizes even before the plugin had a name, but I never did. The reason was that I simply found the concept very hard to understand. I mean, what’s the deal with w and vw?
But that article made me force myself to study the subject, once and for all. And after playing around with it for a few days, I got the #ahamoment.


A couple of weeks later, RWP 1.6 was released. img with srcset/sizes was the new default markup pattern. picture and span were still avaliable as options.
If your template looks like this:

    <h1><?php the_title();?></h1>
    <?php the_content();?>

The output might look like this without RWP:

    <h1>Hello world</h1>
    <p>Lorem ipsum dolor sit amet...</p>
    <img src="" alt="Image description">

But with the plugin installed, the image would become responsive.

    <h1>Hello world</h1>
    <p>Lorem ipsum dolor sit amet...</p>
    <img sizes="100vw" 
        srcset=" 300w, 1024w, <image-width>"
        src="" alt="Image description">

Documentation takes time

As I’ve said on Twitter a lot, it’s not the programming itself that takes time. It’ the writing of documentation.
For instance, I had to write new examples that demonstrated the new markup pattern. I had to add a whole new section to the function reference. And of course, I had to test all the examples to make sure that everything worked properly.


Speaking of testing. I really need to add unit tests to the plugin. For each update, the number of users has grown and it becomes more scary to ship the update.
1.6 was a pretty large update and I’ve promised myself that I’ll never release such an update without unit tests ensuring everything works.
This is also something I’ve wanted to add for a long time. But when I started building the plugin, I found that the learning curve for testing a WordPress plugin was to steep.
But now, when I’ve played around quite a bit with the WordPress test suite, I feel more comfortable with it.
However, a lot of refactoring will be needed to make the entire plugin testable. There are some classes that might do a bit more work than they should be doing. I also wanna try to follow the five SOLID design principles.
With that in mind, a complete rewrite of the plugin would be a good excercise in more than one way.