Template Tags for Blogger Media Enclosure Links
Originally this blog entry had three paragraphs on how difficult it's been for me to find the data tags for media enclosures but nobody wants to read that. What I will say is after years of searching my quest finally came to an end thanks to one Pete Hopkins, a Blogger Developer. All I had to do was ask 'im but I don't like to ask unless I'm certain I looked everywhere. You know, RTFM? Well, in this case the M is really F'ing out of date, but I digress.
Quoth the Hopkins,
It's already available to the blog widget. The post has a list called "enclosures" and its elements have "
url
", "title
", and "mimeType
" properties.
Missing title
Element in the Post Editor
The post editor itself gets in the way of taking full advantage of this. Pete Hopkins mentioned a title
element. Well, in the post editor there's no title
field for media enclosures. I haven't written one yet but I'm thinking a Greasemonkey Userscript could possibly resolve this. Also, you are limited to 255 characters and spaces are not allowed in either field.
Applications of Media Enclosures
Even with these restrictions and the missing title field you have a lot to play with. Obviously most people will use the enclosure links for podcasting but I tend to think outside the box. I’ll show you what I mean with a snippet of template code powering MY STADY:
<b:loop values='data:post.enclosures' var='enclosure'> <!--application/zip == Download--> <b:if cond='data:enclosure.mimeType == "application/zip"'> <a expr:href='data:enclosure.url' rel='enclosure' expr:title='"Download " + data:enclosure.url'>Download ⇣</a> </b:if> <!--application/x-rar-compressed == Download--> <b:if cond='data:enclosure.mimeType == "application/x-rar-compressed"'> <a expr:href='data:enclosure.url' rel='enclosure' expr:title='"Download " + data:enclosure.url'>Download ⇣</a> </b:if> <!--application/x-gzip == Download--> <b:if cond='data:enclosure.mimeType == "application/x-gzip"'> <a expr:href='data:enclosure.url' rel='enclosure' expr:title='"Download " + data:enclosure.url'>Download ⇣</a> </b:if> <!--custom/user-script == Install--> <b:if cond='data:enclosure.mimeType == "custom/user-script"'> <a expr:href='data:enclosure.url' rel='enclosure' expr:title='"Download " + data:enclosure.url'>Install ⇣</a> </b:if></b:loop>
Granted, there's no such thing as a "custom/user-script
" MIMEtype but it works and that's what counts. The download/install links are only displayed on non-item pages. I have plans for more radical things such as entirely transforming how a blog entry is displayed based on its content but I'm in no rush to implement them. There's also the obvious ideas like having a different photo in your headline like they do on Lifehacker or running an MP3 blog. I always examine our options from every angle to make sure I'm doing the right thing by our visitors. Let's be honest, not every new Blogger addition is useful.
To get the most out of this we'll eventually have to alter the post editor with a Greasemonkey Userscript. It's the easiest way. Any other method would require starting from scratch. I might be confusing this with another Google API but I believe you're allowed to include ANY kind of data you want in a post submission. With that kind of freedom you could probably make anything possible like categories. Actually you could do that now with enclosures.
So yeah, I think what I'll do is look into the Greasemonkey thing because I'd really like it if my audio and video posts had RDFa & Facebook Share meta data automatically embedded. If you don't know what that is you should. Here's some links to get you started:
New York photographer, party mammal, and Internet troll for hire. Alain-Christian is an OG who’s been blogging for over 20 years dating back to the early days of AOL. He loves sharing his offbeat opinions on pop culture, bestowing his tech knowledge, and making arts.