Install the Flickr module. That’s going to require a Flickr API key, so follow the instructions to set that up. You’ll need to enable the following modules: Flickr, Flickr Filter, Flickr Sets. Then enable the “Flickr linker” filter under Input Formats.
Keep in mind that only “public” photos work with this.
That’s going to let you put something like
[flickr-photoset:id=72157610617588420,size=s]
in the body of your document. When you save and view this document, you should see little thumbnails from your photoset. If you click on one, it’s going to take you to Flickr. We’ll be replacing that with Highslide.
Okay, so that’s nice but that [flickr-] stuff is a little hard to deal with. So what we’re going to do is install flickrset. This is a plug in I wrote for WYSIWYG and TinyMCE. You place it in
/sites/all/modules/wysiwyg/plugins
Then, in Drupal, go to /admin/settings/wysiwyg and edit any input formats that use TinyMCE. This is probably just “Full HTML.” Under the “Buttons and plugins” section you should see a new checkbox at the end labeled “Flickrset.” Turn that on and save it.
Now when you create a new document, you should see a new button in the body. The new button is the Flickr icon. When you click it, you get a pop up with three fields. You paste the URL of your Flickr photoset in there. You pick the size of the thumbnails you want. You pick the size of the “full size” pictures that you want. You click add. It’s going to build that [flickr-] crap for you.
You’ll see there’s a new thing in there, and that’s “class=showsizen.” This is the parameter for the “full size” picture. This isn’t going to work, out of the box. You’re going to need to hack the Flickr module. *gasp* So open
/sites/all/modules/flickr/flickr.module
and find the theme_flickr_photoset function. Change
$output .= theme('flickr_photo', $photo, $size);
to
$output .= theme('flickr_photo', $photo, $size, NULL, $attribs);
This is important because we’re passing the attributes to the theme function. The attributes contain, among other things, the class parameter we set earlier.
The module will let you pick a number of photos to appear in photosets. That’s nice if all your photosets are going to use the same number of photos, but if you want each gallery to display a different number of photos, you’ll need to add some functionality. Here’s how to do that.
In modules/flickr/filter/flickr_filter.module find flickr_filter_callback_photoset()
// change this line return theme('flickr_filter_photoset', $photoset, $photoset['owner'], $config['size'], $attribs); // to this return theme('flickr_filter_photoset', $photoset, $photoset['owner'], $config, $attribs);
In modules/flickr/sets/flickr_set.module replace flickr_set_load() with
function flickr_set_load($sid, $num = 0, $page = 1) { // TODO: Not sure why this called for /flickr and does not show for admin role if ($num == 0) $num = variable_get('flickr_photos_per_page', 20); if (is_numeric($sid)) { return flickr_request('flickr.photosets.getPhotos', array( 'photoset_id' => $sid, 'page' => $page, 'per_page' => $num, ) ); } }
In modules/flickr/flickr.module find theme_flickr_photoset()
// change the first two lines to this function theme_flickr_photoset($ps, $owner, $config, $attribs = NULL) { $size = $config['size']; // then change this line $photos = flickr_set_load($ps['id']); // to this $photos = flickr_set_load($ps['id'], $config['num']);
Okay, so now if we look at our saved document, we see all the thumbnails there. Each image should have the “showsizen” class we specified. It may be “showsizeb” if you chose that size instead- n is normal, b is large. (These are abbreviations from the Flickr module, I didn’t make them up.) It’s still not going to expand to the correct size, we haven’t gotten that far. Just make sure your images have that class when they get displayed.
The last thing is this jQuery. This is going to hijack the resulting HTML so that Highslide can handle the full sized images.
$(document).ready(function() { $('.flickr-photoset a').each(function() { // we need a slightly different version of the static image url var thumb_url = $(this).children('img').attr('src'); var showsize = ""; if ($(this).children('img').hasClass('showsizeb')) { showsize = "_b"; } if ($(this).children('img').hasClass('showsizen')) { showsize = ""; } var dotpos = thumb_url.indexOf('.jpg'); thumb_url = thumb_url.substr(0, dotpos - 2) + showsize + ".jpg"; // now replace the a.href with this $(this).attr('href', thumb_url); // and fix it up for highslide $(this).addClass('highslide'); this.onclick = function() { return hs.expand(this); } }); });