TanTan Flickr plugin: Show all images from a Flickr album in a blogpost
The TanTan Flickr plugin made by Joe Tan grabs your Flickr sets into your wordpress website. However it is possible to also show all the images grabbed by the plugin in a single blogpost. This post explains how.
You can grab the plugin at Joe Tans website. http://tantannoodles.com
In order to load all images from a set or album in a blogpost you need to
edit some files of the Tantan Flickr Plugin.
Below is a manual which should guide you through it.
Remarks:
Backup your files prior to editing them. I can’t be held responsible for
crashed websites or otherwise any damage. Backups prevent a lot of trouble.
By default, the Flickr API will only show 30 images at once. If you need more
then 30 images, please try it yourself to see how much images will work.
You need to edit 4 files (1 optional):
httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-resources.php
httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-shortcode.html
httpdocs/wp-content/plugins/tantan-flickr/flickr.php
httpdocs/wp-content/plugins/tantan-flickr/flickr/class-public.php
Optional:
httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-styles.css
———————————————————————-
In httpdocs/wp-content/plugins/tantan-flickr/flickr/class-public.php
———————————————————————-
Find:
$error = "Unknown size: $size.";
$size = 'Square';
}
Replace:
$key = "flickr-$album-$tag-$num-$size-$video-$photo";
With:
$albumID = $album;
$key = "flickr-$albumID-$tag-$num-$size-$video-$photo";
if ($html = get_post_meta($post->ID, $key, true)) {
return $html;
} else {
Find:
}
// grab the flickr photos
$photos = array();
$auth_token = get_option('silas_flickr_token');
$baseurl = get_option('silas_flickr_baseurl');
$baseurl_pre = get_option('silas_flickr_baseurl_pre');
$linkoptions = get_option('silas_flickr_linkoptions');
$albumData = array();
Add after:
$album = array();
Find:
$photoInfo = $flickr->getPhoto($photo);
$photoInfo['sizes'] = $flickr->getPhotoSizes($photo);
$html .= TanTanFlickrDisplay::image($photoInfo, $size);
Replace:
} elseif ($album) {
$albumData = $flickr->getAlbum($album);
$photos = $flickr->getPhotos($album);
With:
} elseif ($albumID) {
$album = $flickr->getAlbum($albumID);
$photos = $flickr->getPhotos($albumID);
} elseif ($tag) {
$photos = $flickr->getPhotosByTags($tag);
}
———————————————————————-
Find:
}
$prefix = get_bloginfo('siteurl').'/'.substr($baseurl, strlen($baseurl_pre));
$linkoptions = get_option('silas_flickr_linkoptions');
Replace:
foreach (array_slice($photos, 0, $num) as $photo) {
$html .= TanTanFlickrDisplay::photo($photo, array(
'size' => $size,
'album' => $albumData,
'scale' => $scale,
'prefix' => $prefix,
'linkoptions' => $linkoptions
));
}
With:
if (isset($photos[$album['primary']])) {
$primary = $photos[$album['primary']];
} else {
$primary = $flickr->getPhoto($album['primary']);
$primary['sizes'] = $flickr->getPhotoSizes($album['primary']);
}
ob_start();
include( $this->getDisplayTemplate('photoalbum-shortcode.html'));
$html = ob_get_contents();
ob_end_clean();
} // if count photos
Find and remove:
$html = '<div class="flickr-photos">'.($error ? ('<p class="error">'.$error.'</p>') : '').$html.'</div>';
Add:
$html = '<div class="flickr-photos">'.($error ? ('<p class="error">'.$error.'</p>') : '').$html.'</div>';
if (!update_post_meta($post->ID, $key, $html)) add_post_meta($post->ID, $key, $html);
return $html;
}
———————————————————————-
In httpdocs/wp-content/plugins/tantan-flickr/flickr.php
———————————————————————-
Find:
// clear flickr cache
add_action('tantan_flickr_clear_cache_event', create_function('', 'require_once(dirname(__FILE__)."/flickr/lib.flickr.php");$flickr = new TanTanFlickr();@$flickr->clearCacheStale();'));
Replace with:
add_action('wp_head', create_function('$attribs=false, $content=false', 'require_once(dirname(__FILE__)."/flickr/class-public.php"); if (!is_object($GLOBALS[TanTanFlickrPlugin])) $GLOBALS[TanTanFlickrPlugin] =& new TanTanFlickrPlugin(); return $GLOBALS[TanTanFlickrPlugin]->header();'), 9990);
———————————————————————-
Create httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-shortcode.html
———————————————————————-
Add:
<?php
/*
Copy this file into your current active theme's directory to customize this template
This template displays one Flickr photo set
*/
global $TanTanFlickrPlugin;
?>
<div id="highlight">
</div>
<div id="photos" class="photos">
<?php foreach ($photos as $photo)
echo TanTanFlickrDisplay::photo($photo, array('size' => 'Square' ,'album' => $album));
?>
</div>
<div class="flickr-meta-links">
<a href="http://www.flickr.com/photos/<?php echo $album['owner' ];?>/sets/<?php echo $album['id' ];?>/" target="_blank"><?php _e('View this album on Flickr' , 'tantan-flickr' );?></a>
</div>
———————————————————————-
In httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-resources.php
———————————————————————-
Find:
// return the link to where the photo should go
function href($photo, $album=null, $prefix='') {
return $prefix.'photo/'.$photo['id'].'/'.($album ? ($album['pagename2'].'-') : '').$photo['pagename'];
Replace:
return $prefix.'photo/'.$photo['id'].'/'.($album ? ($album['pagename2'].'-') : '').$photo['pagename'];
With:
return '../../foto/album/'.$album['id'].'/photo/'.$photo['id'].'/'.($album ? ($album['pagename2'].'-') : '').$photo['pagename'];
———————————————————————-
Optional:
———————————————————————-
In httpdocs/wp-content/plugins/tantan-flickr/templates/photoalbum-styles.css
———————————————————————-
Find:
div.meta img {
margin-right:5px;
}
Add after:
div.flickr-photos h2
{
font-weight:bold;
font-size: 150%;
color: #AD2600;
text-align: left;
}
