FlickrGallery
Questions answered by this recipe
How can I add a flickr gallery to my wiki?
Description
Use this recipe to add a flickr gallery to your wiki.
You should be able to run any flickr API method that responds with either photos or photosets. See Notes.
Installation
- Acquire a flickr API key:
- Download phpFlickr API kit:
- Download flickrgallery.php:
- (Optionally) Download slimbox2:
- Place phpFlickr in cookbook folder.
- Place flickrgallery.php in cookbook folder.
- (Optionally) Place slimbox2 in pub folder.
- Add the following to config:
## Include Flickr Gallery. include_once("$FarmD/cookbook/flickrgallery.php"); $FlickrGallery['FlickrAPI'] = '<replace with your flickr API key>';
- Use the following directive on a wiki page:
(:flickrgallery:)
Configuration
The following default variables may be set in your config:
$FlickrGallery['FlickrAPI'] = NULL; $FlickrGallery['FlickrSecret'] = NULL; $FlickrGallery['DieOnError'] = false; $FlickrGallery['EnableCache'] = false; $FlickrGallery['CacheType'] = 'fs'; $FlickrGallery['CachePath'] = $_SERVER['DOCUMENT_ROOT'] . '/cache'; # Also available, but open flickrgallery.php to see default values: $FlickrGallery['HTMLWrapper']; $FlickrGallery['HTML']; $FlickrGallery['HTMLErrorWrapper']; ###### $FlickrAPI['Method'] = 'flickr.photos.getRecent'; # Any flickr API arguments may be set in $FlickrAPI[]. # The following are just a couple of examples: $FlickrAPI['photoset_id'] = '72157628658158003'; $FlickrAPI['per_page'] = '10';
You may wish to review the flickr API for documentation on valid methods and arguments. Also, see Notes.
On a wiki page, directive arguments may override any of the $FlickrAPI[] variables. The following are a couple of valid examples:
(:flickrgallery:) (:flickrgallery photosets.getPhotos photoset_id="72157628658158003":) (:flickrgallery method="flickr.groups.pools.getPhotos" group_id="1336624@N23" tags="deer":)
This probably goes without saying, but for security reasons you definitely do NOT want to include flickr API key or secret information in a directive posted to a publicly editable wiki page.
You can style the appearance of the thumbnails with CSS:
.flickrgallery img { margin: 0.05em 0 0.2em; border: 1px solid transparent; } .flickrgallery img:hover { border: 1px solid #DD6900; }
You may also incorporate lightbox functioning for pretty display and navigation. Add the following to config for slimbox2 use. Be sure to revise the src and href URLs to match your setup.
$HTMLHeaderFmt['slimbox'] = ' <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="/wiki/pub/slimbox/js/slimbox2.js"></script> <link rel="stylesheet" href="/slimbox2.css" type="text/css" media="screen" />';
Notes
You MUST specify a valid flickr API key in config for this recipe to work!
This recipe was built to process publicly accessible flickr images. While any of the available flickr API methods may be called, the script is written to process only the following responses:
<photos ...> <photo ... /> <photo ... /> </photos> <photoset ...> <photo ... /> <photo ... /> </photoset>
A few flickr API methods that are compatible with this recipe include, but not limited to:
- flickr.galleries.getPhotos
- flickr.people.getPublicPhotos
- flickr.photos.search
- flickr.photos.geo.photosForLocation
- flickr.photosets.getPhotos
The method flickr.photos.search really offers a lot of oomph for more complex dealings.
Processing of other flickr API responses could theoretically be written into flickrgallery.php without too much coding effort.
Change log / Release notes
- 2015-01-01: Removed depreciated PHP code.
- 2012-01-21: Beta release. Minor bug fix.
- 2012-01-03: Beta release. Minor bug fixes.
- 2012-01-02: Beta release. Had to back off the claims of what the recipe could do, but it still does process flickr API responses of photos and photosets.
- 2012-01-01: Beta release. Code has been rewritten a lot. It is now simpler, more generic/powerful, and (should be) more stable.
- 2011-12-30: Initial alpha release. Works for my needs (mostly pulling from group pool photos), but I'm sure there are ample bugs.
See also
- Cookbook:FlickrAlbum
- Cookbook:Galleria
- Cookbook:EasyGallery
- Cookbook:ThumbList
- Flash#flickr
- Cookbook:PictureGallery
- Cookbook:EmbeddedGallery
- Cookbook:SimpleGallery
Contributors
Comments
See discussion at FlickrGallery-Talk?
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.