function theme_flickrfield_photoset in Flickr 6
Same name and namespace in other branches
- 5 field/flickrfield.module \theme_flickrfield_photoset()
1 theme call to theme_flickrfield_photoset()
- theme_flickrfield_field_formatter in field/
flickrfield.module - Basic flickrfield formatter.
File
- field/
flickrfield.module, line 507 - Defines a Flickr field type.
Code
function theme_flickrfield_photoset($img, $photo_url, $formatter, $photo_data, $node) {
$class = variable_get('flickr_class', '');
$rel = variable_get('flickr_rel', '');
$output = '<div class="flickr-photoset">';
// 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 (module_exists('flickr_sets')) {
$photos = flickr_set_load($photo_data['id']);
foreach ((array) $photos['photoset']['photo'] as $photo) {
$url = flickr_photo_img($photo, variable_get('flickr_opening_size', ''), $formatter);
$img_url = flickr_photo_img($photo, $formatter);
// If it is not a square.
if ($formatter != 's' && $formatter != 'q') {
// Get the real width of the image.
list($width) = getimagesize($img_url);
}
// Insert owner into $photo because theme_flickr_photo needs it.
$photo['owner'] = $photos['photoset']['owner'];
$title = is_array($photo['title']) ? $photo['title']['_content'] : $photo['title'];
// Image width less than 100 px is too small for most titles.
// Can be set differently on the settings page.
if ($width < variable_get('flickr_title_suppress_on_small', '100')) {
$credit = t('Flickr');
}
else {
$credit = $title;
}
$img = flickr_img($photo, $formatter);
$original = flickr_photo_img($photo);
if (arg(0) == 'node' && arg(1) == $node->nid) {
if (variable_get('flickr_class', '') == NULL && variable_get('flickr_rel', '') == NULL) {
$output .= '<span class="flickr-wrap">' . $img . '</span>';
}
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 the TOS of Flickr.
$output .= '<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 . '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-photoset-img flickr-photoset-img-' . $formatter . '">' . l($img, 'node/' . $node->nid, array(
'attributes' => array(
'title' => $title,
),
'absolute' => TRUE,
'html' => TRUE,
)) . '</div>';
}
}
}
else {
$title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
if (arg(0) == 'node' && arg(1) == $node->nid) {
$output .= '<div class="flickr-photoset-img">' . $img . '</div>';
}
else {
$output .= '<div class="flickr-photoset-img">' . l($img, 'node/' . $node->nid, array(
'attributes' => array(
'title' => $title,
),
'absolute' => TRUE,
'html' => TRUE,
)) . '</div>';
}
}
$output .= '</div>';
$output .= '<div class="flickr-photoset-meta">';
$output .= '<p>' . $photo_data['description']['_content'] . '</p>';
$output .= '<cite>' . l(t('Source: Flickr'), $photo_url) . '</cite>';
$output .= '</div>';
return $output;
}