Flickr Gallery

Description

Using the “shortcodes” system in WordPress 2.5 and up, this plugin will allow you to quickly and easily incorporate your Flickr photos into your WordPress pages and posts.

Features

  • A quick gallery of your recent photos, photosets and most popular photos.
  • Easy database caching (just click a checkbox)
  • Displays photos from a custom search, or specific group or photoset
  • Displays all of a user’s photos with given tags
  • Inserts a single photo into your content
  • Embeds Flickr’s flash movie player for videos
  • Authenticate to display your private photos
  • Lightbox script makes it easy to browse photos without leaving the page
  • Plugin API to let sites configure the tabs in their gallery
  • View photosets in the gallery mode without leaving the page
  • Lightboxes are now generated for every gallery mode
  • WordPress MU Support
  • Pagination in galleries
  • All images smaller than “medium” will load in the lightbox effect (if enabled) when the user clicks on them.
  • New (in 1.3): Add a “Collections” tab to the default gallery
  • New (in 1.3): Select which tabs the gallery displays

How to use this in your site

Once you’ve installed the plugin (search for “Flickr Gallery” in your WordPress admin panel’s “Plugin > Add New” page), go to the plugin’s settings page and follow the instructions to enter your API key and Flickr user ID.  Once that is set up and photos are showing in the test area at the bottom of the settings page, just enter “shortcodes” into the content of your WordPress pages and posts to use Flickr photos.

Shortcode Examples

  • [flickr-gallery] Creates a generic gallery for the user you specified in your settings page.
  • [flickr]http://flickr.com/photos/dancoulter/2619594365/[/flickr] Inserts the given image. You can also just put the photo ID in there (the numeric string at the end of the link).
Additional Options
  • [flickr-gallery mode="photoset" photoset="72157605870230826"] Displays all of the photos from the given Flickr photoset.
  • [flickr-gallery mode="tag" tags="foo" tag_mode="all"] Shows photos from your photostream with the specified tags (comma separated). If you leave off the tag_mode option, it defaults to “any”.
  • [flickr-gallery mode="recent"] Shows recent photos from your photostream
  • [flickr-gallery mode="interesting"] Shows interesting photos from your photostream
  • [flickr-gallery mode="search" tags="foo" group_id="46862018@N00"] The search mode supports any arbitrary search using the options listed here: http://www.flickr.com/services/api/flickr.photos.search.html
  • [flickr size="small" float="left"]http://www.flickr.com/photos/dancoulter/2619594365/[/flickr] Sets the size of the inserted image to “small” (defaults to “medium”) and makes the next paragraph of text wrap around to the right of the image (you can specify “right” for the float parameter as well, which defaults to “none”)
  • [flickr height="300" width="400"]http://www.flickr.com/photos/dancoulter/2422361554/[/flickr] This one is a video. It’ll automatically embed the flash movie for you. If you want to change its size, you can use the width and height options.

Plugin API

This plugin makes use of the WordPress API to let you add and remove tabs from the [flickr-gallery] shortcode’s display with a little PHP code.  Place one (or all) of these snippets in a new WordPress plugin file or in your theme’s functions.php file to get them to work.

Removing the “Most Interesting” photos tab

<?php
add_filter('flickr_gallery_tabs', 'flickr_gallery_remove_tab');
function flickr_gallery_remove_tab($tabs) { 
    unset($tabs[2]);
    return $tabs; 
}
?>

Renaming the “Most Interesting” photos tab

<?php
add_filter('flickr_gallery_tabs', 'flickr_gallery_rename_tab'); 
function flickr_gallery_rename_tab($tabs) { 
    $tabs[2]['name'] = 'My Popular Photos'; 
    return $tabs;
}
?>

Adding a “My Videos” tab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php 
add_filter('flickr_gallery_tabs', 'flickr_gallery_add_videos_tab'); 
function flickr_gallery_tabs($tabs) { 
    $tabs[] = array( 'id' => 'videos', 'name' => 'My Videos', 'callback' => 'flickr_gallery_tab_videos', ); 
    return $tabs; 
} 
 
function flickr_gallery_tab_videos() { 
    global $phpFlickr; 
    $photos = $phpFlickr->photos_search(array(
        'user_id' => '70297824@N00', 
        'per_page' => 30, 
        'media' => "video", 
        "extras" => "media", 
    )); 
 
    ?>
        <div class="flickr-photos">
            <?php foreach ( $photos['photo'] as $photo ) : ?>  
                <div class="flickr-thumb">
                    <a href="http://flickr.com/photos/<?php echo $photo['owner'] . '/' . $photo['id'] ?>">
                        <img
                            class="<?php echo $photo['media'] ?>" 
                            title="<?php echo str_replace('"', '\\"', $photo['title']) ?>" 
                            alt="<?php echo str_replace('"', '\\"', $photo['title']) ?>" 
                            src="<?php echo $phpFlickr->buildPhotoURL($photo, 'square') ?>" 
                        />
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
    <?php
}
 
?>

More Information

Current version: Download 1.5.2
Downloads: 144,244
Requires: WordPress 2.9
Tested up to: WordPress 3.0.5
Last Updated: September 25, 2010
View this plugin on WordPress.org