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 :

102 Responses to “Aligning Images In RSS Feeds”

  1. […] ۱-Align Rss Image: خیلی افزونه‌ی کاربردی‌ای است، باعث می‌شود که چپ‌چین و یا راست چین بودن مطالبتان در در فیدخوان‌ها حفظ شود. خیلی هم کم حجم است! […]

  2. […] Aligning Images In RSS Feeds | W-Shadow.com Plugin de WordPress para darle alineamiento a las imágenes en los feeds (tags: images plugin wordpress align feed) […]

  3. […] correctly listing in the left or right aligned location. Here is a excellent wordpress plugin by w-shadow.com which would allow you in fixing this problem […]

  4. […] Align RSS Images is one of many plugins offering this functionality and probably the easiest to use: upload/install the plugin, activate it and enjoy looking at your own entries with properly aligned images in your feed from now on. […]

  5. Qwoter says:

    Great plugin – exactly what i needed to fix the images in my RSS feed.

    Thanks!

  6. […] you subscribe to a blog by RSS feed, you’ll know that images can appear all over the place. Align RSS Images makes sure that the images in a feed are in the same place as they are on the actual […]

  7. […] la que j’ai découvert le plugin « Aligning images in RSS feeds » qui permet de faire ce traitement sur le contenu pour ajouter des balises style avec […]

  8. Bob says:

    I don’t think this works in Google Reader

  9. White Shadow says:

    Just checked Google Reader. The image alignment looks to be working on this end. Perhaps you’re using custom image CSS that’s not recognized by the plugin?

  10. […] – Align Rss Image : خیلی افزونه*ی کاربردی*ای است، باعث می*شود که چپ*چین و […]

  11. […] auto­ma­ti­sierte Lösung, die Bil­der im Feed so wie im Blog zu posi­tio­nie­ren bie­tet ein klei­nes Plu­gin namens Align-RSS-Images, das den Feed jeweils mit der rich­ti­gen Posi­tio­nie­rung der Ele­mente ver­sieht.  Das […]

  12. […] correctly listing in the left or right aligned location. Here is a excellent wordpress plugin by w-shadow.com which would allow you in fixing this problem […]

  13. Raphael says:

    I usually insert images with captions, that is inside a div. Now the div is aligned, not the image. Can your plugin be extended to handle divs also?

  14. White Shadow says:

    Yes. You need to add the appropriate class-name and style rules to the $explicit_alignment_styles array in rss-image-align.php.

    For example, lets say your HTML structure looks like this :

    ...

    …and your CSS looks like this :

    .left-aligned-div {
        float: left; 
        padding: 4px;   
    }

    In this case, you would need to add a line like this to the .php file :

    'left-aligned-div' => 'float: left; padding: 4px;',
  15. […] post and they align nicely, things won’t look as pretty when you get the post in a feed reader. This plugin aligns images in your RSS feed so they are exactly where they would be on your […]

  16. Brian says:

    I love this plugin, but it broke in WP 3.01. I’ve been up two nights scrounging img alignment tweaks but no luck.

  17. White Shadow says:

    It seems to be working fine on my test site(s). Are you sure it’s the 3.0.1 update that caused it to break, not a conflict with another plugin or something?

  18. Brian says:

    Only other formatting plugins are WP-Columns and TinyMCE Adv. I gotta *confess to monkeying around* with 3.0’s hot new editor-styles. Now the .alignment conflicts drive me nuts because I’m too much of a noob. I don’t know the css hierarchy order or which files are read first, so I got stuck in a mess. My site is OK. The WYSIWYG editor is repaired mostly OK. I’m ready for a clean install to take another crack at it. Thanks for your reply Shadow.

  19. White Shadow says:

    Well, the plugin expects alignment to be specified via certain CSS classes – “alignleft”, “aligncenter”, “alignright” and so on. Normally the post editor will automatically furnish each image with the right classname. But if you start using a different method to align your images the plugin will no longer be able to tell how they’re supposed to be aligned.

    In that case, you should add your custom CSS classes – if that’s what you use – to the $explicit_alignment_styles array in rss-image-align.php.

Leave a Reply