With the Flickr module you can display images from Flickr in various ways. On thing you can’t do out of the box is to display a perticular photoset with multiple thumbnails. Say you have the content type news and every news item is associated with a perticular Flickr photoset. When viewing the news item you want to display the photoset below the node body.
So how do you go about making this happen? Well, the Flickr module ships with several different blocks, none however lets you input a photoset id. The blocks provide more versatile functionality such as displaying the latest images by a user, the latest photoset and so on. So instead we turn to the Flickr modules CCK addition, the Flickr field. The Flickr field lets you define a field that accepts either a photo or photoset id. To enable the photoset feature you need to activate the module Flicker Sets which shipps with the Flickr module.
The first step is to add a Flickr field to a content type, in our case the news content type. Once you added the field make sure to visit the Display tab and setup the preferred image display size. Now lets create a new news item and input a valid Flickr user id and photoset id.
Once we have added the Flickr field to our news content type and created our first post it may take a while for the photoset to show up in your newly created news post. When it shows up you will see that it only shows the cover photo from the photoset and displays a link to the photoset at flickr.com. That is not the desired behavior. We want all the images to display in a nice list. To make this happen we need to override som theme functions. If you don’t already got a template.php file in your theme create one.
In the template.php file we will override the function theme_flickrfield_photoset. Look at the code below:
function yourthemename_flickrfield_photoset($img, $photo_url, $formatter, $photo_data, $node) {
return theme_flickr_photoset($photo_data, $photo_data['owner'], $formatter);
}
Thats all it’s to it. Now the photoset will render as a complete set with a pager available when the photoset is larger then 20 photos.
In my case I also wanted the photoset images to open in a Fancybox window instead of linking to flickr.com. To make this happen you need to override another theme function, see below.
function yourthemename_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
$img = flickr_img($p, $size, $attribs);
$photo_url = flickr_photo_img($p, NULL, $format);
$title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
return l($img, $photo_url, array('attributes' => array('rel' => 'photos', 'title' => $title), 'absolute' => TRUE, 'html' => TRUE));
}
The attribute rel=”photos” is required to enable image browsing with Fancybox.
October 20th, 2009
by Nicolas
Thanks for this post. I was just looking for a solution to display flickr photos in a drupal website. I’ll give this a try !
October 28th, 2009
by Nicolas
I tried it, and I got it to work. But I have some questions:
- How to install fancybox? I used the lightbox2 module and it works
- When opening the node I see the complete set of pictures, but they are put one against the other without space and spread over a few rows. How could I get one row with a left and right arrow to view all the thumbnails of the set? Or where would I be able to change the spacing between the pictures?
Thanks for your help !
October 28th, 2009
by admin
The Author
Well, fancybox has no Drupal module that I know of. So just put in in your themes folder and include it either via the theme .info file or directly in your page.tpl.php.
You can style the photoset via your themes CSS or create a separate CSS-file and include it exactly like described above.
If you want the photoset like a carousel (left and right arrow) try out http://sorgalla.com/projects/jcarousel/examples/static_simple.html
July 21st, 2010
by Meho
I tried this, using the default garland theme i suppose i have to edit the template.php file in the theme/garland folder and change the youthemename bit to garland right?
I did that but still only shows cover photo though.
July 22nd, 2010
by peter
The Author
You must have missed something then. Hard to give any advice without further information.