MTRecentImages is a plugin for Movable Type (http://www.movabletype.org) that allows you to pull out a list of the most recent images from the posts on your weblog.
<MTRecentImages num_images="10"> <img src="<$MTRecentImageUrl$>" alt="<$MTRecentImageName$>" <$MTRecentImageWidth$> <$MTRecentImageHeight$> /> <br/> <$MTRecentImageName$>
MTRecentImages is used to work with the most recent images in the posts on your weblog. You could use this to make a list of the most recent images as a sidebar, an ATOM or RSS feed, or to simply make a gallery page of you most recent images.
The plugin can also generate thumbnails or small details of the images it comes across.
UPDATE: I have changed the processing to include both entry and extended entry. I should probably make this a preference, but it should be ok for now.
MTRecentImages is NOT a full featured gallery script, nor will it become one. I have one of those already. ;)
Place this file in your Movable Type plugins directory, and add something like the above synopsis to a template of your choosing.
This plugin requires Movable Type (obviously) and HTML::TokeParser, available on the CPAN. I will look into packaging HTML::TokeParser with this plugin, but it may be overkill. If you choose to use the image thumbnailing, you will also need Image::Magick. If you have Image::Magick installed already (hint: check your mt-check.cgi page to double check. If you can have MT make thumbnails for you already, then you have Image::Magick installed.).
UPDATE: I have removed the dependency on Image::Magick::Thumbnail. Since the module was one subroutine, i have just pulled it in here. Credit goes to Lee Goddard <LGoddard@CPAN.org> for creating Image::Magick::Thumbnail and for saving me a ton of hassle while I was initially coding this module.
use constant NUM_IMAGES => 10;
Set NUM_IMAGES to the number of images that you would like to populate the tag by default.
MTRecentImages is the main context tag that will allow you to use the RecentImages plugin. It works in the same way as MTEntries or MTCategories, in that it simply sets populates the data for loop you will use to print out your images.
Parameters that can be passed in to the plugin to make it filter or exclude certain types of images, or to simply limit the number of images pulled.
MT will silently pass over tags that return undefs. I found this out while puzzling over why when I requested 10 images I would only get 8. Turns out images 9 and 10 did not have ALT tags, which are used for the names. For shame, for sure, but this will be a common scenario for many people. replace_blank_alt will substitute your given text for an empty ALT tag.
This works just like the normal MT offset tag. An offset of N will skip the first N images.
The maximum number of images to pull out.
Only pull images from posts of a certain category. This requires you to pass in the numeric ID for the category.
Same as only_category, but you can pass in the name of the category.
Skip images from the specified category. This requires you to pass in the numeric ID for the category.
Same as exclude_category, but you can pass in the name of the category.
Only pull images matching the specified width. NOTE: to keep the requirements light for this module, I am relying on the HTML that is listing the original image to pull the width. If i get around to it, i will add some optional real image checking, but it is more complicated that I feel like dealing with tonight.
Only pull images matching the specified height. See NOTE above.
Only pull images matching the specified type.
Exclude any images matching the specified type.
If this is set, then thumbnails of the images will be written out to this directory. As with any file-writing CGI, your web server will need write permissions to be able to successfully make the thumbnails. This requires the Image::Magick::Thumbnail module. Will require that other thumbnail parameters are also set. See below.
This pair of parameters will determine the maximum size of the thumbnails for each image.
If this is set, then small, random details of the images will be written out to this directory. These differ from the thumbnails in that they show a portion of the image at actual size as opposed to a tiny version of the whole image. As with any file-writing CGI, your web server will need write permissions to be able to successfully make the details. Will require that other thumbnail parameters are also set. See below.
This pair of parameters will determine the maximum size of the details for each image.
Sort the list by the specified parameter.
MTRecentImageUrl is the source URL for the image in question. This tag is only valid in an MTRecentImages block. As of right now, this will simply mimic the src tag of the image. It will not transform a relative URL into an absolute URL.
MTRecentImageName is the ALT text for the image in question. This tag is only valid in an MTRecentImages block. I should make another configuration variable to deal with missing ALT tags. Perhaps the default title could be ``Shame on you.''
MTRecentImageWidth is the width of the image in question. This tag is only valid in an MTRecentImages block. This is useful if you want to spit out the image on a page, rather than simply linking to it.
MTRecentImageHeight is the height of the image in question. This tag is only valid in an MTRecentImages block. This is useful if you want to spit out the image on a page, rather than simply linking to it.
MTRecentImageEntryUrl is the permalink of the entry in which the image was found. This is useful if you want to link to not just the image, but the source article.
MTRecentImageEntryTitle gives the title of the entry in which the image was found.
The text of the entry that the image is in.
The extended text of the entry that the image is in.
The excerpt text for the entry that the image is in.
The URL and size of the generated thumbnail, if available.
The URL and size of the generated detail, if available.
MTRecentImages is written by Jason Gessner ( email@example.com ) and is free to use and modify, under the condition that proper credit is given and that further modifications, should they be released to the public, be linked to this original as well. Share and share alike, but play nicely, please.
Special thanks to Ari Paparo (http://www.aripaparo.com/), who added the MTRecentImageEntryUrl and MTRecentImageEntryTitle parameters. Thanks, Ari!
The most recent version of this plugin will always be found at http://www.multiply.org/perl/mtplugs/.