Closed (fixed)
Project:
Image Caption
Version:
6.x-2.x-dev
Component:
Miscellaneous
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Apr 2009 at 21:18 UTC
Updated:
1 Mar 2011 at 21:56 UTC
I'm not using a WYSIWYG editor to add images inline, rather the image cache module. I have manually added the following code to the node.tpl file:
<?php $attr['class'] = 'right caption';
print theme('imagecache', 'presetname_lg', $node->field_image[0]['filepath'], $alt, $title, $attr ); ?>
For some reason, image cache is not displaying the alt information. Instead, the "title" information is displayed as the caption...and the image title always prints the title of the node! In addition, if there is NO image displayed on a particular node, image_caption displays the div anyway, along with the "title" values.
This is the generated markup for the page (from the code above):
<div class="image-caption-container" style="width: 300px;">
<img class="right caption" width="300" height="225" align="" title="PHY (Assistance to the Physically Challenged)" alt="" src="http://www.adrayemen.org/sites/default/files/imagecache/programs_lg/Picture 665resize.jpg"/>
<div class="image-caption">PHY (Assistance to the Physically Challenged)</div>
</div>
Note how the "alt" value is empty, and the title is actually the title of the node.
Comments
Comment #1
pepemty commentedsubscribing
Comment #2
mrtcereal commentedI'm rather new to php and Drupal, but I stumbled across this post while trying to get this module to work together with Image Cache and Content Templates, and this seems to be working for me. Hope it helps.
Comment #3
bradweikel commentedThis is an imagecache issue, not image_caption.
Note that the caption = title behavior is the expected behavior for the image_caption module, so the only (possible) issue is with the alt attribute in the theme call.
Comment #4
zoltán balogh commentedsubscribing
Comment #5
bradweikel commentedNot sure what I was thinking back in January, but looking at this again it seems the issue is pretty simple:
In node.tpl.php, $title is the node title and there is no defined $alt, so the result is exactly what you'd expect. The suggested fix in #2 is the correct one: it passes the title and alt values from the actual image field.
Comment #7
justinchev commentedJust in case it helps anyone I was trying to render out the title and alt tags in a custom template using imageCache in conjunction with Ubercart and this is what got it working for me - noting what is used for the the ALT and TITLE :
print theme('imagecache', 'presetName', $first['filepath'], $node->field_image_cache[0]['data']['alt'], $node->field_image_cache[0]['data']['title']);