function theme_flickrfield_photo in Flickr 6
Same name and namespace in other branches
- 5 field/flickrfield.module \theme_flickrfield_photo()
Flickrfield photo themes.
If we are not on the node, make the photo link back to the node, otherwise just display the image. To comply with Flickr terms of service add a link back to the Flickr page.
1 theme call to theme_flickrfield_photo()
- theme_flickrfield_field_formatter in field/
flickrfield.module - Basic flickrfield formatter.
File
- field/
flickrfield.module, line 447 - Defines a Flickr field type.
Code
function theme_flickrfield_photo($img, $photo_url, $formatter, $photo_data, $node) {
$class = variable_get('flickr_class', '');
$rel = variable_get('flickr_rel', '');
$url = flickr_photo_img($photo_data, variable_get('flickr_opening_size', ''), $formatter);
$img_url = flickr_photo_img($photo_data, $formatter);
// If the image is a square we know the width (avoids to make a request).
switch ($formatter) {
case 's':
$width = '75';
break;
case 'q':
$width = '150';
break;
}
// If it is not a square.
if (!isset($width)) {
// Get the real width of the image.
list($width) = getimagesize($img_url);
}
$title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
// Image width < 100 px is too small for most titles. Can be set differently.
if ($width < variable_get('flickr_title_suppress_on_small', '100')) {
$credit = t('Flickr');
}
else {
$credit = $title;
}
if (arg(0) == 'node' && arg(1) == $node->nid) {
if (variable_get('flickr_class', '') == NULL && variable_get('flickr_rel', '') == NULL) {
$output = '<div class="flickr-photo-img">' . $img . '</div>';
}
else {
// Final step that generates the image with a link to the bigger version
// and a link to the Flickr page under it to comply with Flickr's TOS.
return '<span class="flickr-wrap">' . l($img, $url, array(
'attributes' => array(
'title' => $title,
'class' => $class,
'rel' => $rel,
),
'absolute' => TRUE,
'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',
),
)) . '</span></span>';
}
}
else {
$output = '<div class="flickr-photo-img">' . l($img, 'node/' . $node->nid, array(
'attributes' => array(
'title' => $title,
),
'absolute' => TRUE,
'html' => TRUE,
)) . '</div>';
}
$output .= '<div class="flickr-citation"><cite>' . l(t('Source: Flickr'), $photo_url) . '</cite></div>';
return $output;
}