function theme_flickr_photo in Flickr 6
Same name and namespace in other branches
- 5 flickr.module \theme_flickr_photo()
- 7 flickr.module \theme_flickr_photo()
3 theme calls to theme_flickr_photo()
- theme_flickr_block_photo in block/flickr_block.module
- theme_flickr_filter_photo in filter/flickr_filter.module
- theme_flickr_photoset in ./flickr.module
File
- ./flickr.module, line 216
Code
function theme_flickr_photo($photo, $size = NULL, $format = NULL, $attributes = NULL) {
$class = variable_get('flickr_class', '');
$rel = variable_get('flickr_rel', '');
$url = flickr_photo_img($photo, variable_get('flickr_opening_size', ''), $format);
$img = flickr_img($photo, $size, $attributes);
$img_url = flickr_photo_img($photo, $size);
switch ($size) {
case 's':
$width = '75';
break;
case 'q':
$width = '150';
break;
}
if (!isset($width)) {
list($width) = getimagesize($img_url);
}
$photo_url = flickr_photo_page_url($photo['owner'], $photo['id']);
$title = is_array($photo['title']) ? str_replace('"', "'", strip_tags($photo['title']['_content'])) : $photo['title'];
$info = flickr_photo_get_info($photo['id']);
$description = !empty($info['description']['_content']) ? str_replace('"', "'", htmlspecialchars_decode(strip_tags($info['description']['_content']))) : $title;
$username = !empty($info['owner']['realname']) ? l($info['owner']['realname'], 'https://www.flickr.com/photos/' . $info['owner']['nsid'], array(
'attributes' => array(
'title' => t('View user on Flickr.'),
'target' => '_blank',
),
)) : l($info['owner']['username'], 'https://www.flickr.com/photos/' . $info['owner']['nsid'], array(
'attributes' => array(
'title' => t('View user on Flickr.'),
'target' => '_blank',
),
));
$taken = isset($info['dates']['taken']) ? format_interval(time() - strtotime($info['dates']['taken']), 1) . ' ' . t('ago') : '';
$neighbourhood = isset($info['location']['neighbourhood']['_content']) ? strip_tags($info['location']['neighbourhood']['_content']) . ', ' : '';
$locality = isset($info['location']['locality']['_content']) ? strip_tags($info['location']['locality']['_content']) . ', ' : '';
$region = isset($info['location']['region']['_content']) ? strip_tags($info['location']['region']['_content']) . ', ' : '';
$country = isset($info['location']['country']['_content']) ? strip_tags($info['location']['country']['_content']) : '';
$location = !empty($country) ? ' ' . t('at') . ' ' . $neighbourhood . $locality . $region . $country : '';
$metadata = '<br />' . $taken . $location . ' ' . t('by') . ' ' . $username;
$credit = $width < variable_get('flickr_title_suppress_on_small', '100') ? t('Flickr') : $title;
$metadatacaption = $width < variable_get('flickr_metadata_suppress_on_small', '150') ? '' : $metadata;
$overlay = variable_get('flickr_info_overlay', array(
'title' => 'title',
'metadata' => 'metadata',
'description' => 'description',
));
$overlaytitle = gettype($overlay['title']) == 'integer' ? '' : $title . ' - ';
$metadata = gettype($overlay['metadata']) == 'integer' ? '' : $metadata . ' - ';
$description = gettype($overlay['description']) == 'integer' || $overlaytitle == $description . ' - ' ? '' : $description;
$overlayhtml = $overlaytitle . $metadata . $description;
if (variable_get('flickr_class', '') == NULL && variable_get('flickr_rel', '') == NULL) {
return l($img, $photo_url, array(
'attributes' => array(
'title' => $title,
),
'absolute' => TRUE,
'html' => TRUE,
));
}
else {
return '<span class="flickr-wrap">' . l($img, $url, array(
'attributes' => array(
'title' => $overlayhtml,
'class' => $class,
'rel' => $rel,
),
'html' => TRUE,
)) . '<span class="flickr-credit" style="width: ' . ($width - variable_get('flickr_caption_padding', '0')) . 'px;">' . l($credit, $photo_url, array(
'attributes' => array(
'title' => t('View on Flickr. To enlarge click image.'),
'target' => '_blank',
),
'html' => TRUE,
)) . $metadatacaption . '</span></span>';
}
}