Internet / WordPress · September 17, 2007 1

Possible solution to FeedBurner Email Subscription Problem (Images not appearing in the emails)

Email Icon Large

FeedBurner Email Subscriptions are a great way to spread your blog’s content far & wide – by sending your post feeds directly to the inbox of your subscribers. It’s a particularly viable option for the subscribers who don’t want to get into the hassle of firing up their feed reader every day. Quite a few of my regular subscribers utilise this method.

I’ve always kept a tab on each my feeds using a standard feed reader (FeedReader) and since they appeared fine to me I never really bothered to check on the email based feeds. Recently, I received a bunch of complaints from the email subscribers regarding “broken images” in the emails. Doing a quick check confirmed the reports – the images embedded in the posts were indeed missing. Instead they are replaced by the standard “broken image” icon. It took me a while to figure out the real problem – since the same feed(s) turned up just fine in any given feed reader.

The Problem

Broken Chain

The root of the problem lies in how one embeds images and/or links in the posts – i.e. in the absolute or relative URL formats. To save up on typing, I’ve always resorted to relative URLs when specifying the source of the images in my posts. This actually is a good practise since this enables you to transfer your site to another domain without any ensuing hiccups over broken links and images. However, this doesn’t always translate properly in case of RSS/Atom feeds. The best thing to do in such cases is to use absolute URLs – so that the images in the feeds get displayed properly when they are viewed independently of the site or even when incorporated in someone else’s site.

As for me, I don’t follow the standardised WordPress approach of uploading all the images under the /wp-content/uploads/ directory. I have my own folder called /postimage/ where I manually upload the pictures and then link them in the relative format. For example, /postimage/image_file.jpg.

When my site is viewed directly in a browser or through a feed reader, the images are automatically located in relation to the site root, i.e. https://chaos-laboratory.com and thus displayed properly. For emailed feeds, the image source attributes get converted to https://postimage/image_file.jpg – which naturally doesn’t make any sense to your browser.

The Solution

Your best bet out here, is to device some mechanism where you can still use the relative URLs in your posts – but they automatically get translated to the absolute form (inclusion of your domain name before the folder and file information) in case of feeds.

The first method involves some messy editing of the WordPress feed publishing files (found in the /wp-includes/ folder). In any standard WordPress installation, they’re the PHP files starting with the word feed (feed-atom.php, feed-rss2.php etc). You can edit these files and implement Regular Expression matching routines to replace any relative links with the absolute form. This is more of a pro-coder approach.

The second method is to use a readily available WordPress plug-in named URL Absolutifier which works in a similar way – but translates all your relative URLs to their absolute forms for both your site and feeds. This is the approach I’ve taken up for the time being. Currently I am testing out this plug-in and will report my findings shortly. If it manages to fix my problem, I’ll try and implement the code directly into the feed publishing engine (mentioned in the first method).

Any thoughts on this ?