Looking for a user-friendly solution to printing a photo's description.

I figured out that I could call flickr_photo_get_info() to find the description, but I'm not sure where to add it.

To make the description appear with the lightbox after the title, I themed theme_flickr_photo in template.php, but it feels like a hack to me. Any suggestions for integrating this better into some configuration options or improving the theme function?

/**
 * Theme flickr photos.
 */
function mobius_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
  $info = flickr_photo_get_info($p['id']);
  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
  if (is_array($info['description'])) {
    $description = $info['description']['_content'];
  }
  else {
    $description = $info['description'];   
  }
   if (is_array($p['title'])) {
    $p['title']['_content'] .= l(' (view photo on flickr.com)', $photo_url, array('attributes' => array('target' => '_blank')));
    $p['title']['_content'] .= '<br /><span class="description">'. $description .'</span>';
    $title = $p['title']['_content'];
  }
  else {
    $p['title'] .= l(' (view photo on flickr.com)', $photo_url);
    $p['title'] .= '<br /><span class="description">'. $description .'</span>';
    $title = $p['title'];
  }
  $img = flickr_img($p, $size, $attribs);
  return l($img, $photo_url, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE));
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jumpfightgo’s picture

FileSize
540.71 KB

You can see an example of this in action in the attached screengrab and at http://www.mobius.org/photos/artist/6?page=1

alison’s picture

I love what you did there, so I'm definitely want to subscribe and see how it ends up (sorry I'm not much help, personally -- though I'll try out your theme code, and report back how it goes).

Anonymous’s picture

Assigned: Unassigned »
Anonymous’s picture

Assigned: » Unassigned
nate.klingerman’s picture

I am interested in how you completed this. You placed the code above in the template.php file? Where did you call the function, and did you have to modify anything else to make it work?

Anonymous’s picture

Very interesting , ill have to find some time to work on this .

Best,
Paul Booker
Appcoast

lolandese’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
75.96 KB
28.05 KB

Attached patch:

  • Backports #1937738: A configurable image size for overlay browser links. from D7
  • Backports #2163647: Unnecessary white space next to image from D7
  • Fixes some code style errors suggested by Code Sniffer (drush dcs)
  • Adds more code comments
  • Adds the description to the image 'title' attribute (shows on hover). If no description is available the title will be used instead.
  • Adds the description optionally to the info displayed when enlarging an image in an overlay browser (the link 'title' attribute). HTML is stripped, double quotes are removed (it goes into the title="[description]" attribute) and special characters are decoded (&copy; turns into ©). If title and description are identical, only one is used.
  • Adds date, location and photographer info to the caption on images of a certain width (configurable) and optionally also to the info displayed when enlarging an image in an overlay browser. The date is in the form of 'time ago'. The photographer's Real Name is used, if not available the Username instead. In the caption it links to the user page on Flickr.

The attached image shows the new settings page.

TO DO:

Thanks.

New settings page for Flickr D6

lolandese’s picture

Status: Needs review » Fixed
lolandese’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Patch (to be ported)

Port to D7.

lolandese’s picture

Status: Patch (to be ported) » Needs review
FileSize
8.88 KB
lolandese’s picture

Remove the existing instance of form element in flickr.admin.inc:

$form['flickr_title_suppress_on_small'] = array(
....

If not it appears double.

lolandese’s picture

Add license info as a possible piece of info to give even more complete attribution in the caption (optional, checkbox selected by default).

lolandese’s picture

Title: photo descriptions support » Photo descriptions support plus date taken, location and photographer

Changed title to cover the changes by the submitted patch

lolandese’s picture

Reroll to include #11.

lolandese’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.