ResolveURLs is a Movable
Type plugin by Alexei Kosut to resolve
relative URLs in weblog entries. It adds a new global filter
resolve_urls that can be used in any MT template tag.
Enabling this causes relative URLs to be resolved against your
weblog site URL, and output as absolute.
This is useful, as relative URLs are convenient to type, but unsafe, since weblog entries can be seen from a number of different pages (e.g., from the index or from an archive page), each of which might resolve a relative URL differently. RSS feeds make the problem of relative URLs even worse, since your links may end up on another site where relative URLs will not point to your pages at all.
Current version: 1.0.2
- Movable Type. I have only tested with version 2.51, although others may work.
- URI. I think this is indirectly required by MT, though, so you probably already have it installed.
To install, copy
ResolveURLs.pl into your Movable
resolve_urls="1" to any template tag where you
want relative URLs expanded. For example, to display the body of an
entry with URLs expanded, you might use:
The filter will search for any HTML tags with
src attributes, and make sure the corresponding URLs are
absolute. Relative URLs are resolved against the weblog site URL, as
configured in Movable Type.
resolve_urls filter can be used in any template
tag where a weblog is in context. I use it in my weblog for all
tags, to make sure no relative URLs sneak out.
- Does not resolve fragment-only URLs (e.g.,
#foo), since these usually refer to anchors inside the entry itself, and are “safe” for encapsulation.
- Recognizes link attribute values delimited with single or no quotation marks as well as those with double quotation marks.
- Before resolving relative URLs, adds a trailing slash to the site URL if there isn’t one already.
- Initial release
- Currently, the HTML “parser” is not very smart, and it’s possible it might identify URLs that aren’t actually links that should be expanded.