Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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));
}
Comment | File | Size | Author |
---|---|---|---|
#14 | description_and_metadata_for_D7-688572-14.patch | 9.65 KB | lolandese |
#10 | description_and_metadata_for_D7-688572-10.patch | 8.88 KB | lolandese |
#7 | description_and_metadata-688572-7.patch | 28.05 KB | lolandese |
#7 | Flickr_new_settings_D6.jpeg | 75.96 KB | lolandese |
#1 | Picture 1.png | 540.71 KB | jumpfightgo |
Comments
Comment #1
jumpfightgo CreditAttribution: jumpfightgo commentedYou can see an example of this in action in the attached screengrab and at http://www.mobius.org/photos/artist/6?page=1
Comment #2
alisonI 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).
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #5
nate.klingerman CreditAttribution: nate.klingerman commentedI 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?
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedVery interesting , ill have to find some time to work on this .
Best,
Paul Booker
Appcoast
Comment #7
lolandese CreditAttribution: lolandese commentedAttached patch:
©
turns into ©). If title and description are identical, only one is used.The attached image shows the new settings page.
TO DO:
Thanks.
Comment #8
lolandese CreditAttribution: lolandese commentedTested also with Lightbox2.
Committed. See http://drupalcode.org/project/flickr.git/commitdiff/c6b8b9a.
Comment #9
lolandese CreditAttribution: lolandese commentedPort to D7.
Comment #10
lolandese CreditAttribution: lolandese commentedComment #11
lolandese CreditAttribution: lolandese commentedRemove the existing instance of form element in flickr.admin.inc:
If not it appears double.
Comment #12
lolandese CreditAttribution: lolandese commentedAdd license info as a possible piece of info to give even more complete attribution in the caption (optional, checkbox selected by default).
Comment #13
lolandese CreditAttribution: lolandese commentedChanged title to cover the changes by the submitted patch
Comment #14
lolandese CreditAttribution: lolandese commentedReroll to include #11.
Comment #15
lolandese CreditAttribution: lolandese commentedhttp://drupalcode.org/project/flickr.git/commitdiff/787adba