Aligning Images In RSS Feeds

When inserting an image into a post, WordPress lets you choose an alignment (left/right/center/none) and even add a caption. This usually works well when viewing the post on the blog itself, but will often look messed-up in the RSS feed. Basically, the image becomes unaligned and breaks the intended post layout. I’ve found an easy way to fix it.

As it turns out, the problem appeared when WP developers chose to remove the deprecated “align” attribute from the WordPress-generated <img> tags. Now, following web standards is all well and good, but what if you still want to align an image in a way that works in the feed, too? The typical answer is to add a style="float:left;" (or “float:right;”) attribute to each aligned image. However, that would become very bothersome if you had to manually edit the HTML code every time.

So I created a plugin that will do it automatically.

Plugin Description

“Align RSS Images” is a simple plugin that scans your RSS feed and ensures that every image has the correct alignment and margin settings. Technically speaking, it finds HTML elements styled with any of the WordPress-generated classes and appends an appropriate style attribute to each element. This is done dynamically when the feed is generated, so your actual posts won’t be modified.

Left-aligned picture in a RSS feed

Sidenote : Yes, I know that using styles in a RSS feed isn’t exactly standards-compliant either. Nevertheless, it works fine with Google Reader and the W3C Feed Validator says the feed is OK. So most likely the sky won’t fall on your head if you use this plugin 😉

Download

align-rss-images.zip (2 KB)

Requirements : WordPress 2.6 or later
Installation : Just upload and activate. The plugin is completely automated, but due to caching you may need to wait a few hours for the changes to appear in your RSS reader.

Related posts :

103 Responses to “Aligning Images In RSS Feeds”

  1. I used a wordpress Plugin to add Images to Rss Feed. It’s good If you share Posts via ifttt or Something Like that. But to bei honest: isnt this pointless for small Websites?

  2. Kai says:

    Its so usefull to know this, thanks for the article

  3. Joel says:

    Nice Article. Images in RSS Feeds is something, that’s not used too often nowadays – but it totally should.

Leave a Reply