Adding Media Enclosure Links to Blogger Layouts

Adding Media Enclosure Links to Blogger Layouts

Originally this blog entry had three paragraphs on how difficult it's been for me to find this 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. 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.


Limitations


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 neither field.

Applications


Even with these restrictions and the missing title field you have a lot to play with. Here's an excerpt from the 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='&quot;Download &quot;
+ data:enclosure.url'>Download &#x21e3;</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='&quot;Download &quot;
+ data:enclosure.url'>Download &#x21e3;</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='&quot;Download &quot;
+ data:enclosure.url'>Download &#x21e3;</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='&quot;Download &quot;
+ data:enclosure.url'>Install &#x21e3;</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:

2 Comments

Ankush Bakshi - #
February 23, 2011 at 2:42 AM
How Do i Remove MEDIA ENCLOSURE link in my blog. My blog is http://www.jobs-in-2011.blogspot.com , thank you..
Alain-Christian - #
March 21, 2011 at 11:25 PM
I'm not sure what you mean.

Add a Comment