Closed (fixed)
Project:
ImageField
Version:
6.x-3.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2007 at 17:40 UTC
Updated:
26 Oct 2014 at 16:27 UTC
Jump to comment: Most recent
It would be great if a caption could be added to the images so that it would appear within the imagefield div.
Comments
Comment #1
quicksketchYour best bet here is to use the image title as a caption. You can use contemplate module or theme_imagecache (if using imagecache) to display the title underneath the image rather than as it's title attribute. I think this has already come up in discussion and vetoed, though I can't find the original issue.
Comment #2
Robardi56 commentedCan you please give an example with Contemplate ?
I currently add something there but it loops and display first title only once. This is a problem because I have multiple image.
THnaks,
Brakkar
Comment #3
quicksketchYep sure can do :)
Assume your field name is called 'image', and therefore 'field_image' in the mind of CCK:
Comment #4
aether commentedThanks for the insight and suggestions. I have been trying to accomplish this with theme_imagecache and my weak php skills with no luck so far. An example here would be appreciated as well. Thanks again.
Comment #5
quicksketchTheme imagecache is definitely a way to go also. Put this in your theme's template.php file:
Replace garland_ with the name of your theme followed by an underscore.
Comment #6
aether commentedThank you for this. Works like a charm. I had a CSS border around my image that was rendering even when there was no image present in the node. I added an if conditional so that no html is output if there is not an image present.
Comment #7
dopry commentedYep those theme functions are powerful... :)
Comment #8
simonlagneaux commentedThis is exactly what I needed! Thanks, you made my day!
Comment #9
tokko commentedRequests for adding captions seem to pop up once in a while. Can anyone remember why this request keeps on getting vetoed? A caption would be a logical feature for an imagefield.
Anyway, if one wants to avoid adding extra modules for doing this, adding the feature (an easily css-themable div with a caption) requires only modding one line in imagefield.module. Of course this is bad practice if forking ImageField is not the intention, but that might become practical as well if there's no desire for the IF people to add the feature officially?
Comment #10
brambor commented@tokko,
Which one line of code would that be?!? I'm not really at a point with Drupal where I should be hacking modules, but I'm going crazy trying to find a workable way to add the fields 'caption' and 'credit' in addition to 'title'. The lack of an ability to add attribution and captioning really limits the utility for me, of what is otherwise a pretty slick module.
Any suggestions you (or others) might have would be most appreciated.
BTW - I'm using Drupal 6.1 - not sure if it is bad form to change that in the "Edit issue settings" above.
Comment #11
geerlingguy commentedI added the code from #5 to my template.php, which gracefully adds captions to all the areas I need it to; however, the captions are also showing in areas I'd rather *not* have a caption, such as on the front page. Here's the site in question:
http://stlouisreview.com/
I was wondering if you could help me figure out what I need to do to make the caption only appear on article-type pages... I tried wrapping
$output .= '<div class="caption">'. check_plain($title) .'</div>';in a "if (!$is_front) wrapper, but that didn't do anything.I tried this:
But that didn't seem to work. It still showed up, after clearing the theme registry.
Comment #12
bcobin commentedThank you, thank you, thank you for this. Changing to current release version of 6.x because #6 works nicely with current version. Thank you again!
Comment #13
himagarwal commentedI added the #6 code to template.php and it works fine. Now, when I remove it I'm getting errors.
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'simple_imagecache' was given in /home/site/simple/includes/theme.inc on line 668.
There were several error lines like above (maybe 20) but for ease I removed all as all of them were exactly same.
How to correct this error?
Comment #14
himagarwal commentedOk! Flushed the cache, and everything now seems to be working fine.
However, such error should not be there, isn't it?
Comment #15
himagarwal commentedI added the #6 code to template.php but all the imagecache has now caption. How can I specify a particular or multiple imagecache in this code?
Comment #16
mlehew commentedHow can the #6 code be modified to work in D7? This seems like it would be a clear-cut solution to solve the captions problem, but I'm not skilled with custom PHP.
Comment #17
jackalope commentedhimagarwal: I also needed only certain imagecache presets to display the caption. Here's how I got the code to work so that the caption is only displayed for the preset named "fullnode":
Comment #18
asb commentedWhy can't it be a field formatter setting to display a caption? To my understanding, that's what field formatters are made for.