You are here

function flickr_photo_img in Flickr 7

Same name and namespace in other branches
  1. 5 flickr.inc \flickr_photo_img()
  2. 6 flickr.inc \flickr_photo_img()

Returns the URL to $photo with size $size using the correct image farm from the $photo variable.

Parameters

string $photo: Photo to which the url should point.

string $size: Size of the photo.

string $format: Format of the photo.

Return value

array URL for $photo with the correct size and format.

2 calls to flickr_photo_img()
flickr_img in ./flickr.inc
This function will try to create an html image tag referencing the Flickr photo with the desired size if that size is available for this photo.
theme_flickr_photo in ./flickr.module
Theme Flickr photo.

File

./flickr.inc, line 368
The Flickr API functions.

Code

function flickr_photo_img($photo, $size = NULL, $format = NULL) {

  // Early images don't have a farm setting so default to 1.
  $farm = isset($photo['farm']) ? $photo['farm'] : 1;
  $server = $photo['server'];

  // photoset's use primary instead of id to specify the image.
  $id = isset($photo['primary']) ? $photo['primary'] : $photo['id'];
  $secret = $photo['secret'];
  $suffix = $size ? "_{$size}." : '.';
  $suffix = $size == '-' ? '.' : $suffix;
  $extension = $size == 'o' ? $format : 'jpg';
  return "https://farm{$farm}.static.flickr.com/{$server}/{$id}_{$secret}" . $suffix . $extension;
}