function flickr_img in Flickr 5
Same name and namespace in other branches
- 6 flickr.inc \flickr_img()
- 7 flickr.inc \flickr_img()
This function will try to create a html image tag referencing the Flickr photo with the desired size if that size is available for this photo.
Parameters
$photo: the photo variable
$size: the desired image size
$attribs: an optional array of HTML attributes to pass to the image
Return value
a html image tag referencing the image of the desired size if it is available.
5 calls to flickr_img()
- flickrfield_field_formatter in field/
flickrfield.module - Implementation of hook_field_formatter().
- theme_flickr_photo in ./
flickr.module - theme_flickr_photoset in ./
flickr.module - theme_flickr_photo_box in ./
flickr.module - theme_flickr_sets_photoset_box in sets/
flickr_sets.module
File
- ./
flickr.inc, line 150
Code
function flickr_img($photo, $size = NULL, $attributes = NULL) {
$sizes = flickr_photo_sizes();
if (!isset($size)) {
$size = '-';
}
if (!isset($sizes[$size])) {
return;
}
if (!isset($attributes) || !is_array($attributes)) {
$attributes = array();
}
// photoset's use primary instead of id to specify the image.
if (isset($photo['primary'])) {
$id = $photo['primary'];
$attributes['class'] = implode(' ', array(
$attributes['class'],
'flickr-photoset-img',
));
}
else {
$id = $photo['id'];
$attributes['class'] = implode(' ', array(
$attributes['class'],
'flickr-photo-img',
));
}
if ($size == 's') {
$attributes['height'] = $attributes['width'] = 75;
$img_url = flickr_photo_img($photo, $size);
}
else {
$image_sizes = flickr_photo_get_sizes($id);
if ($image_sizes) {
foreach ($image_sizes as $image_size) {
if ($image_size['label'] == $sizes[$size]['label']) {
break;
}
}
if (isset($image_size)) {
$img_url = $image_size['source'];
$attributes['height'] = $image_size['height'];
$attributes['width'] = $image_size['width'];
}
}
else {
$img_url = flickr_photo_img($photo, $size);
}
}
$title = is_array($photo['title']) ? $photo['title']['_content'] : $photo['title'];
return theme('image', $img_url, $title, $title, $attributes, FALSE);
}