The Daily Dilbert – Considerations

DilbertI spend this weekend some time on building the extra features for the Daily Dilbert plug-in. In case you are wondering: yes, “plug-in”, since it’s no longer just a simple widget.  It turned out to be a rather nice challenge.

The first part – adding a template insert function – was peanuts. Call the function in your template and it will render the wider widget version of the Daily Dilbert widget as supplied by UFS. I did spend some time to make the plug-in cleaner. All text fragments are now in a separate template file which gets included. All this in-line HTML was giving me a bad rash. While I was at it, I did the same for the widget.

Now for the more complex part.

I pretty much thought I’d figured it out. Just fire up SimplePie (which is part of the WordPress framework) fetch the feed, take out the image url and post it in the content. Simple eh? Not quite.

For one, I noticed that the Dilbert panels were pretty wide. To make a comparison, the default wordpress template (and pretty much all the templates based on this template) has about 450 pixels space in width; the Dilbert panels are 560 pixels wide.
In short, they don’t fit.

Scaling the source is not really an option. Most browsers *cough IE cough* are not very eloquent in scaling down graphics, resulting in text and what not to become illegible clumps. And even if that were the case, not all themes have the same width.

The solution to this problem comes with modern day WordPress blogs, which are empowed by something called the media library. One of the features of the media is that it allows image content to be rescaled and cropped for specific goals, which can furthermore be configured.

However this option makes the whole operation vastly more complex than originally planned. Where I first had to strip the file from the rss feed and put it in a post, now I would have to extract the source url, download the image, add it to the media library, hope it scales the images automagically, somehow figure out the right view size and then insert this to a new post.

Doesn’t quite sound that simple anymore eh?

Of course, there’s the option of simply adding a configuration option which uses a image manipulator and store these images in their own container.

Tempting… tempting, but no.

I am not a big fan of stepping outside the framework and make my own routines. Although it might look faster, it actually isn’t. History tells us that reinventing the wheel never was more efficient, nor that it ever result in a wheel worked better than the round one.
The other downside is that you will create a maintenance nightmare for anyone who uses the plug-in and I don’t want that black spot on my soul.

I guess the next update on the plug-in will take a bit longer than expected. I might do an ‘in between’ release so that the template feature is incorporated, depending on how much time I think it will take.