« FormatList v1.0 - Easy Bullet Lists in Entries | Main | Flickr Photos v0.75 - Many New Features »

FlickrPhotos - A Flickr Plugin for Movable Type

Flickr photos is a plugin that enables you to display thumbnail links of Flickr photos in your Movable Type blog.

You can list thumbnails by Filckr user and/or by Flickr tags. You can also control the number of thumbnails displayed and the size of the thumbnails. Each thumbnail can link to a larger version of the image, or to the Flickr page for that photo.

Here is an example of the easiest way to use FlickrPhotos in your templates:

<MTFlickrPhotos username="John Smith">
<MTFlickrPhotoLink> <br />
<br />
</MTFlickrPhotos>

The above template code will display thumbnail links for the 10 most recent photos for Flickr user "John Smith". (Tip: when entering the value for your 'username', you should use the name that appears after "Logged in as" on the top of each Flick page when you are logged in. Your user name may contain spaces - if so, be sure to include those space as I have done with "John Smith" above).

Here another example that displays thumbnail links from any user tagged with "movabletype":

<MTFlickrPhotos tags="movabletype">
<MTFlickrPhotoLink> <br />
<br />
</MTFlickrPhotos>

FlickrPhotos Template Tags

FlickrPhotos includes the following template tags:

  • MTFlickrPhotos is container tag for displaying photos. Arguments include:
    • username - restricts photos to a specific Flickr user. Required if a tags argument is not included.
    • tags - retricts photos to those with the specified tags. Multiple tags can be specified, separated by comma. Required if a username argument is not included.
    • tag_mode - specifies the method for displaying photos by the tags argument. If tag_mode is set to 'any', it will display photos with at least one on the tags specified in tags. If tag_mode is set to 'all', it will only display photos tagged with each and every one of the tags specified by tags. Optional (the default value is 'any').
    • lastn - determines the number of photos to display. Optional (default is 10 photos).
    Example tag with all arguments included: <MTFlickrPhotos username="John Smith" tags="movabletype,hacks" tag_mode="all" lastn="5">
  • MTFlickrPhotoThumb outputs the URL to the thumbnail image. The size of thumbnail is determined by the FlickrPhotos plugin settings (see below). Example usage: <img src="<MTFlickrPhotoThumb>">
  • MTFlickrPhotoURL outputs the destination URL that can be used to link each thumbnail. This URL will be to either to the Flickr photo page or directly to a different size of the photo (as determined by the plugin settings). Example usage: <a href="<MTFlickrPhotoURL>">
  • MTFlickrPhotoTitle outputs the Flickr title for the photo. This can be used as "alt" text for the thumbnails, and/or used a caption for each photo.
  • MTFlickrPhotoLInk combined each of the above tags - it outputs a linked thumbnail, using the title as the 'alt' and 'title' for the link. The link will open in a new window. This tag is the easiest way to use FlickrPhotos, becuase you don't have to write any HTML for creating the link or displaying the image.

FlickrPhotos Plugin Settings

There are two settings which you can set on a pe-blog basis. To access these settings, select the blog you want and then choose "Settings" from the menu. Then choose the "Plugins" tab. You should then see FlickrPhotos in the list of plugins - hit the settings link to display the settings. The two settings are:

  • Thumbnail Size: This setting determines the size of the thumbnail images. Choice are Square, Thumbnail, Small, Medium, and Orginal. These sizes correspond to the sizes used by Flickr. The default is Thumbnail.
  • Link to: This setting determines where each thumbnail will link to. You can link directly to a different size of the photo (you can choose from the same sizes as above) OR you can link each photo to the Flickr page for that photo. The default is Flickr Page.

Requirements:

  • MT 3.2 (it may work with earlier versions, but I have not tried)
  • Flickr::API Perl Module (included in download for convenience)
  • XML:: Parser::Lite and XML:: Parser::Lite::Tree (included for convenience)

Download Now

Download the plugin by clicking here.

Installation

  1. Expand the zip file and upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation and the contents of the 'extlib' folder to the 'extlib' folder of your MT installation.
  2. Adjust the plugun settings if desired (see above)
  3. Start using the above template tags in your templates.

As always, please let me know if you find any bugs, or if you have any suggestions or comments.

Rate this entry:

  • Currently 4.5/5
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 4.5/5 (11 votes cast). Powered by the Ajax Rating plugin.

Comments (18)

If I hacked your hack to provide size information, would you be willing to consider back patching that in? The application I have in mind for this requires the pixel sizes of the images.

P.S. You have two copies of FlickrPhotos.pl in the distribution.

P.P.S. In terms of code structure, I have a whole bunch of comments. Heh.

* Why do you repeat the API key in multiple places instead of 'use constant' or even an 'our' variable?

* You should look at moving most of the code to an ancillary file that loaded only if the plugin is used, instead of loading that big chunk 'o code every time anything is done in MT. Look at AutoBan for an example of how to do that.

Mark:

Thanks for the comments, AOG.

Yes, if you want to add a pixel dimensions feature, I would definitely add that in. Thanks.

Regarding having 3 copies of FlickrPhotos.pl -- thanks for letting me know, I will look into that right away.

Regarding the API key, the answer is laziness :blush: mostly. I know that I really should do that.

I will try to implement your last suggestion too. The general answer to these questions is that I am quite a novice when it comes to programming. When I do things like this, much time is spent, digging for tutorial content to try to figure out how to achieve what I want. I am sure there are more than a few best practices that I am not following ;)

Well, I already have a working copy, if you'd like to see it :wink:. I'll mail you a copy, along with some other commentary.

erika:

This is fantastic - thanks for creating it. :-)

Any way to grab random photos instead of the last picture uploaded?

Kelly Author Profile Page:

Hi

I am mere novice with Moveable Type but I do know that it's a fantastic creation.

I use it for RSS mostly and want to include images along side my news feed.

I have successfully installed flickr but I just don't know how to use it. Can anybody help me out here.

Best regards

Kelly :-(

Hi,
Is there any way to get the photos to wrap horizontally on a page?

Erika

Erika, can you be more specific? What exactly do you want to do? Using the template tags, you can add breaks or other markup between each photo to customize the way that they are displayed.

acb Author Profile Page:

Can I repeat Erika's earlier request? Is there a way to get the plugin to choose random photos from a set, rather than always the most recent uploaded? I would like the display of photos to rotate once a day or so, to make readers' lives more interesting.

Andrew Brown

Great plugin, was wondering if there was away to add some additional elements into the output url as want to integrate with a lightbox effect?

Essentially I want to add...rel="lightbox[name]" to the url

Faramarz:

The only reason i hesitate to download this plugin is because of the lacking essential; the EXIF output. i.e. shutter speed, aperture, iso etc... is there anyway i can request that to be added? is it even a possibility?

Great site never-the-less and i thanks in advance

True enough, John. This one has been on my todo list for some time, after several people requested it. It just took me a while to get

hillary:

hey, great plug-in... i've found a problem though. when changing the settings to have the thumbnail link to the original (size) photo, the link doesn't work. could it be because "original" is spelled incorrectly in the dropdown menu of the flickrphotos settings?

hillary:

still having issues with linking...
not all the thumbnails have the right URL:
http://vomitlaunch.com/multimedia/photos/promo_thumbs.php
the last one is missing the flickr username from the URL so the link doesn't work, yet all the others work. it makes no sense. and it's not just this page, this is just a simple example.

i've tried waiting for things to cache, republishing the MT blog, deleting then re-adding the photo to the flickr set, even emailing mark. nothing.

help!

If I hacked your hack to provide size information, would you be willing to consider back patching that in

Dammit!
I just typed a whole long message, but when I tried to submit it my Internet Explorer crashed.
Was it somehow saved or is it lost and I have to do it again?

I had to comment since your post was really interesting, but I was wondering If the US senate has a hard time understanding the new health care bill from Obama how can common folks? When will we be able to understand what he has done?

Jo:

I keep getting this error, when trying to rebuild:

Flickr request failed: API returned an invalid response

Can anyone tell me what I'm doing wrong?

Post a comment