Custom Asset Insertion Markup

Awesome! I finally got this working how I want it to. This is a plugin which allows you to alter the HTML markup which is used when an asset is uploaded to an MTOS blog.

This really should be a built-in template, and as I understand it, some developers are trying to get Six Apart to make it so, but in the meantime, this plugin does the trick.

For my use, I made a few small changes to the default template.

AssetThumbnailURL

First I changed the image.thumbnail template, as its the only one I use:

<mt:SetVarTemplate name="image_thumb">
    <a href="<$mt:AssetURL$>" title="<$mt:AssetLabel encode_html="1"$>">
        <img alt="<$mt:AssetLabel encode_html="1" class="thickbox"$>"
             src="<$mt:AssetThumbnailURL width="$thumb_width" height="$thumb_height" $>" 
             <$mt:var name="dimensions"$>
             <$mt:var name="asset_class_attr"$> />
     </a>
</mt:SetVarTemplate>

What did I change? I added the width and height attributes to the AssetThumbnailURL tag so that the URL returned includes the correct height and width dimensions. Without them, a “thumbnail” of the original size is also created, which I don’t need.

I also added the class=”thickbox” attribute because I use the jQuery thickbox plugin for cool, simple, and non-intrusive popups.

Enclosure

For some reason, the asset enclosure (the code which tells MTOS that an asset is getting used) was not wrapping the html output by default, and since I always want it to be used, I changed:

<mt:if name="enclose">
    <$mt:var name="enclosure"$>
<mt:else>
    <$mt:var name="output_html"$>
</mt:if>

to simply:

<$mt:var name="enclosure"$>
By Albert on August 7, 2009 2:16 PM

Categories: