In a template file, before print render($content['field_image']);
I would like to add a CSS class to the image in the $content['field_image']
render array. How can I do this?
Here is the render array:
Array
(
[#theme] => field
[#weight] => 2
[#title] => Image
[#access] => 1
[#label_display] => hidden
[#view_mode] => full
[#language] => und
[#field_name] => field_image
[#field_type] => image
[#field_translatable] => 1
[#entity_type] => node
[#bundle] => ll_basic_page
[#object] => stdClass Object
[#items] => Array
(
[0] => Array
(
[fid] => 6777
[alt] => alt text
[title] =>
[uid] => 1
[filename] => imageFile.jpg
[uri] => public://imageFile.jpg
[filemime] => image/jpeg
[filesize] => 28742
[status] => 1
[timestamp] => 1314312382
[rdf_mapping] => Array
(
)
)
)
[#formatter] => image
[0] => Array
(
[#theme] => image_formatter
[#item] => Array
(
[fid] => 6777
[alt] => alt text
[title] =>
[uid] => 1
[filename] => imageFile.jpg
[uri] => public://imageFile.jpg
[filemime] => image/jpeg
[filesize] => 28742
[status] => 1
[timestamp] => 1314312382
[rdf_mapping] => Array ()
)
[#image_style] =>
[#path] =>
)
)
And this is the HTML output:
<div class="field field-name-field-image field-type-image field-label-hidden" thmr="thmr_96">
<div class="field-items">
<div class="field-item even">
<span thmr="thmr_97">
<span thmr="thmr_98">
<img typeof="foaf:Image" src="http://..../sites/default/files/imageFile.jpg" alt="alt text" />
</span>
</span>
</div>
</div>
</div>
I tried adding a class to $content['field_image']['#attributes']['class']
, but that didn't work.
Do you have any idea on how I can achieve what I am trying to do?