Each time you upload an image into an entry in Movable Type, an 'association' between that image and the post is created. So the image is not just some HTML code inserted in the post, no, there is an actual relationship stored in the database too. This allows you to do fun stuff in your template code: listing all the images associated to a post? No problem, just bring out the <mt:entryassets> tag and loop right over them.
The fun thing about this tag is that as it puts each successive asset in context inside the loop it encloses, you can use any asset-related tag in Movable Type's arsenal. Want to display a list of thumnails linking to the full version of all images in an entry? Use this:
<mt:entryassets type="image">
<a href="<mt:asseturl>"><img src="<mt:assetthumbnailurl width="50" height="50">"></a>
</mt:entryassets>
<a href="<mt:asseturl>"><img src="<mt:assetthumbnailurl width="50" height="50">"></a>
</mt:entryassets>
I just ran this little snippet for all entries in this blog, and this was the result:
Jazzing this up just a little more to also display post titles (and to only display something if the entry actually has an image):
<mt:entries>
<mt:entryassets type="image" limit="1">
<mt:if tag="asseturl">
<a href="<mt:asseturl>"><img src="<mt:assetthumbnailurl height="30">"></a>
<a href="<mt:entrypermalink>" style="font-size:30px"><mt:entrytitle></a><br>
</mt:if>
</mt:entryassets>
</mt:entries>​
<mt:entryassets type="image" limit="1">
<mt:if tag="asseturl">
<a href="<mt:asseturl>"><img src="<mt:assetthumbnailurl height="30">"></a>
<a href="<mt:entrypermalink>" style="font-size:30px"><mt:entrytitle></a><br>
</mt:if>
</mt:entryassets>
</mt:entries>​
The result:
Movable Type 4.34 is out
Premature end of Script Headers, Error 500, Movable Type and You
Automatically Posting Movable Type Entries to Twitter
Using Movable Type Template Tags to Count Things
Template Syntax Highlighting in Movable Type Templating Entries
Making (some) Movable Type 4 Plugins Work on Movable Type 5
Making (some) Movable Type 4 Plugins Work on Movable Type 5
Fighting Comment Spam on Movable Type: What To Do First
Fighting Comment Spam on Movable Type: What To Do First
How to deal with mt-search.cgi causing high load on your server?
Protecting (parts of) your Movable Type site with a password
Can't call method "..." on an undefined value...
Premature end of Script Headers, Error 500, Movable Type and You
Automatically Posting Movable Type Entries to Twitter
Using Movable Type Template Tags to Count Things
Template Syntax Highlighting in Movable Type Templating Entries
Making (some) Movable Type 4 Plugins Work on Movable Type 5
Making (some) Movable Type 4 Plugins Work on Movable Type 5
Fighting Comment Spam on Movable Type: What To Do First
Fighting Comment Spam on Movable Type: What To Do First
How to deal with mt-search.cgi causing high load on your server?
Protecting (parts of) your Movable Type site with a password
Can't call method "..." on an undefined value...
Not bad for something created in five minutes, no?
Tweet
Hey great post!
I was wondering if there is a way to display the html element of the height and width from <mt:assetthumbnailurl>
For example: <img src="<mt:assetthumbnailurl height="30">" height="30" width="xxx">
In this case I want to display the "xxx" width size.
There is the function tag <mt:assetproperty image_height> but this only applies to the original image size.
Do you have any idea how to display this info?
harrods
What a data of un-ambiguity and preserveness of valuable experience concerning unpredicted emotions.