In the render array of an image with link, i tried to add the class 'colorbox-load' to the link, i.e. the <a> tag of the link, but i can't get the adding of the class to work:

$node = node_load(52);
$my_image = field_view_value('node', $node, 'field_image', $my_image[0], array(
          'type' => 'image',
          'settings' => array(
          'image_style' => 'thumbnail',
          'image_link' => 'content',

$my_image['#path']['path'] = 'http://www.example.com';
$my_image['#attributes']['class'][] = 'colorbox-load';

What am i doing wrong?

1 Answer 1


To get your class on the image's link you'll need to set it in the path options:

$my_image['#path']['options']['attributes']['class'][] = 'colorbox-load';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.