Displaying a Thumbnail of an Entry Image with the Title of a Post

| 2 Comments | No TrackBacks
Movable Type's WYSIWYG editor makes it super easy to upload one or more images in any post.  Resizing them and moving them around a bit is also a snap in most cases.  But what if you want to display the titles of your most recent entries somewhere else, preferably with a thumbnail pic of one of the images in the post?  Are you stuck with also displaying the entire body of the post to get at the image(s)?  Of course not!
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">
<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">
<href="<mt:asseturl>"><img src="<mt:assetthumbnailurl height="30">"></a>
<href="<mt:entrypermalink>" style="font-size:30px"><mt:entrytitle></a><br>
</mt:if>
</mt:entryassets>
</mt:entries>

The result:


Not bad for something created in five minutes, no?

No TrackBacks

TrackBack URL: http://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/25

2 Comments

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

I think patients need to understand that if they want their solo/two-doctor group to be there in the future that they will have to accept an alternative payment model (i.e. cash pay). Some of the future changes will certainly be welcome, such as new technologies that make both patient’s and doctor’s work easier and more efficient, but there will also be less-desired changes of more governmental interference, red tape, and an increase of insurance companies’ efforts to collect as much money from the patient and give as little as possible to providers. By breaking this unhealthly addiction to insurance/government patients would find their doctor to be able to provide a much better quality of care. I hope it happens.

Leave a comment