function photo($photo, $options = null) { if (!is_array($options)) { $options = array(); } $defaults = array('size' => 'Square', 'scale' => 1, 'album' => null, 'context' => null, 'prefix' => '', 'linkoptions' => null); $options = array_merge($defaults, $options); extract($options); if ($context == 'gallery-index' && $album) { $prefix = 'album/' . $album['id'] . '/'; } if ($linkoptions == 'flickr' && is_array($photo['urls'])) { $href = array_pop($photo['urls']); } else { $href = TanTanFlickrDisplay::href($photo, $album, $prefix); } $html = '<a class="tt-flickr tt-flickr-' . $size . '" href="' . $href . '" ' . ($album ? 'rel="album-' . $album['id'] . '" ' : '') . 'id="photo-' . $photo['id'] . '" ' . 'title="' . htmlentities($photo['title'], ENT_QUOTES, 'UTF-8') . strip_tags($photo['description'] ? ' - ' . $photo['description'] : '') . '">' . TanTanFlickrDisplay::image($photo, $size, $scale) . '</a> '; return $html; }
function getShortCodeHTML($attribs = false, $content = false) { global $post; extract(shortcode_atts(array('album' => null, 'tag' => null, 'video' => null, 'photo' => null, 'num' => 5, 'size' => 'Square', 'scale' => 1), $attribs)); $error = ''; if (!in_array($size, array('Square', 'Thumbnail', 'Small', 'Medium', 'Large', 'Original'))) { $error = "Unknown size: {$size}."; $size = 'Square'; } $key = "flickr-{$album}-{$tag}-{$num}-{$size}-{$video}-{$photo}"; if ($html = get_post_meta($post->ID, $key, true)) { return $html; } else { $html = ''; } // 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(); $photos = array(); if ($auth_token) { require_once dirname(__FILE__) . '/lib.flickr.php'; $flickr = new TanTanFlickr(); $flickr->setToken($auth_token); $flickr->setOption(array('hidePrivatePhotos' => get_option('silas_flickr_hideprivate'))); $user = $flickr->auth_checkToken(); $nsid = $user['user']['nsid']; if ($video) { $sizes = $flickr->getPhotoSizes($video); $html .= TanTanFlickrDisplay::video($sizes['Video Player']); } elseif ($photo) { $photoInfo = $flickr->getPhoto($photo); $photoInfo['sizes'] = $flickr->getPhotoSizes($photo); $html .= TanTanFlickrDisplay::image($photoInfo, $size); } elseif ($album) { $albumData = $flickr->getAlbum($album); $photos = $flickr->getPhotos($album); } elseif ($tag) { $photos = $flickr->getPhotosByTags($tag); } } else { $html .= '<p class="error">' . __('Error: Flickr plugin is not setup!', 'tantan-flickr') . '</p>'; } if (count($photos)) { if (file_exists(TEMPLATEPATH . '/photoalbum-resources.php')) { require_once TEMPLATEPATH . '/photoalbum-resources.php'; } else { require_once dirname(__FILE__) . '/../templates/photoalbum-resources.php'; } $prefix = get_bloginfo('siteurl') . '/' . substr($baseurl, strlen($baseurl_pre)); $linkoptions = get_option('silas_flickr_linkoptions'); foreach (array_slice($photos, 0, $num) as $photo) { $html .= TanTanFlickrDisplay::photo($photo, array('size' => $size, 'album' => $albumData, 'scale' => $scale, 'prefix' => $prefix, 'linkoptions' => $linkoptions)); } } // if count photos $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; }