If you, like me, type in relative URLs to images and links that are local to your server, you probably didn’t know that means images in your feed are broken. Feeds require absolute URLs for both your images and your links.
This plugin is super minimalistic. It simply looks for any relative URLs you have written, images and links alike, and makes them absolute. This is done after you’ve saved your posts, but before they are shown, so there’s no need to update all your old posts. Just activate the plugin, and voila.
Before:
<a href="/photostream/albums/various/cow.png"> <img src="/photostream/albums/various/cow.png" alt="" /> </a>
After:
<a href="http://noscope.com/photostream/albums/various/cow.png"> <img src="http://noscope.com/photostream/albums/various/cow.png" alt="" /> </a>
Isn’t “media/cow.jpg” a relative path and “/media/cow.jpg” absolute?
Hmmm. Yeah, I guess you have a point there. Right now it’s compatible with your latter example, but I’m not sure it’s compatible with the former. It could be made to, though… something for the todo list.
I’m sorry I keep making all your simple plugins more complicated!
Oh, that’s not so complicated. It’s still very few lines of code. And your corrections are most welcome.
Nice idea Joen, I always forget about people coming in from feed readers and other external sources.
If I get a chance I might play with this at home, see if I can get some simple regex going to detect for URLs that don’t start with “http://”, “ftp://” or other protocols and then selectively replace all links with full URLs.
That would be most excellent.