NAME

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.


SYNOPSIS

  <MTRecentImages num_images="10"> 
    <img src="<$MTRecentImageUrl$>" alt="<$MTRecentImageName$>"
        <$MTRecentImageWidth$>
        <$MTRecentImageHeight$> /> 
    <br/>
  <$MTRecentImageName$>


DESCRIPTION

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. ;)


INSTALLATION

Place this file in your Movable Type plugins directory, and add something like the above synopsis to a template of your choosing.


REQUIREMENTS

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.


TAGS AND CONFIGURATION

Default Number of Images

  use constant NUM_IMAGES => 10;

Set NUM_IMAGES to the number of images that you would like to populate the tag by default.

MTRecentImages

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.

MTRecentImages parameters

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.

replace_blank_alt

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.

offset

This works just like the normal MT offset tag. An offset of N will skip the first N images.

num_images

The maximum number of images to pull out.

only_category

Only pull images from posts of a certain category. This requires you to pass in the numeric ID for the category.

only_category_name

Same as only_category, but you can pass in the name of the category.

exclude_category

Skip images from the specified category. This requires you to pass in the numeric ID for the category.

exclude_category_name

Same as exclude_category, but you can pass in the name of the category.

only_width

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_height

Only pull images matching the specified height. See NOTE above.

only_type

Only pull images matching the specified type.

exlude_type

Exclude any images matching the specified type.

thumbnail_dir

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.

th_width, th_height

This pair of parameters will determine the maximum size of the thumbnails for each image.

detail_dir

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.

det_width, det_height

This pair of parameters will determine the maximum size of the details for each image.

TODO: order_by

Sort the list by the specified parameter.

Output Tags

MTRecentImageUrl

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

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

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

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

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

MTRecentImageEntryTitle gives the title of the entry in which the image was found.

MTRecentImageEntryText

The text of the entry that the image is in.

MTRecentImageEntryTextMore

The extended text of the entry that the image is in.

MTRecentImageEntryTextExcerpt

The excerpt text for the entry that the image is in.

MTRecentImageThumb, MTRecentImageThumbW, MTRecentImageThumbH

The URL and size of the generated thumbnail, if available.

MTRecentImageDetail, MTRecentImageDetailW, MTRecentImageDetailH

The URL and size of the generated detail, if available.


AUTHOR & CONTACT

MTRecentImages is written by Jason Gessner ( jason@multiply.org ) 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/.