Product Development and Internet Marketing

A couple of months ago I added a "photos" feature to EverythingNY where I list the most recently updated blog entries for NY-based photobloggers. I can't speak for my readers, but this has become my favorite thing to do on the site. I quickly scan the titles, and check out the newest images of the city.

But text links only go so far. I really wanted to pull in the actual images (or thumbnails) from the photobloggers. I tried a bunch of different approaches using regular expressions and even writing my own MT plugin, but this was just too much for my amateur coding skills. Then, behold! Someone else did the hard work for me with a great new plugin.

So as a first experiment, I've written some code to a) create an image archive (Example); and b) create an image-only RSS feed (Example).

To start, you need to install the MTRecentImages plugin. The original updated version is available here. This plugin allows you to use an <MTRecentImages> container tag to iterate through your most recent images. I found that I really wanted to also access tags relating to the entries in which these images were found, so I created an extended version of the plugin, available here which Jason quickly updated into the original. If you use the original you will have to remove the <MTRecentImagesEntryUrl> and <MTRecentImagesEntryTitle> tags from the templates below.

Image Archive

In addition to the MTRecentImages plugin, you'll need the MTGrid plugin to create a nice two-column layout. Here's the code:

<table width="577" cellspacing="5" cellpadding="5" border="0"> <MTGrid num_columns="2">

<MTRecentImages num_images="25">
<MTGridCell>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
<td align="center" width="50%">
<a href="<MTRecentImageEntryUrl>" title="<$MTRecentImageName$>"><img src="<$MTRecentImageUrl$>" <$MTRecentImageHeight$> <$MTRecentImageWidth$> border="0"></a><br />
<a href="<MTRecentImageEntryUrl>" title="<$MTRecentImageName$>"><$MTRecentImageEntryTitle$></a>
</td>
<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridCell>
</MTRecentImages>
</MTGrid>
</table>

You can change the number of columns, column widths, number of images, etc pretty easily. Remember the MTRecentImagesEntry... tags only work with the enhanced version of MTRecentImages.

Image RSS

To generate an RSS feed I modified the index.rdf default MT template and added some MTRecentImages tags. Unfortunately, for some reason I couldn't get the template to validate using the standard "encode_url" tag so I had to use a regex hack which requires the MTRegex plugin as well.

Since RSS doesn't have any image-specific tags within the <item> fields, I extended the RSS with height, width, and entrylink fields (e.g. <item:height>). Don't know if this is kosher, but it validates, so that's enough for me. Please, if people who actually know what they are doing read this, don't be shy -- tell me why this is a stupid idea.

The template can be downloaded here. Once again, you must use the extended version of MTRecentImages for certain fields to work.

February 12, 2004 03:08 PM
Comments

Ari,

I've implemented the MTRecentImages plugin as extended, and have a minor problem. For some reason, the image links created on my main index page link to the daily archive, and not the actual individual archive. I've put a code snippet below. Any help you can give would be greatly appreciated.

Thanks

code:

Recent Images


">" height="20%" width="20%" border="1" color="000" />

The URL of the page is http://gerenm.net/pages/index.html

Posted by: GerenM on May 24, 2004 01:29 PM