In my content type I have created a custom field field_image_style which is a list (text).

How can I print its value in node.tpl.php?

print render($content['field_image_style']);

This doesn't work?

(What I actually want to achieve later is to use the selection the user made in field_image_style to apply a specific image style to the images of the content element.)

EDIT: Somehow the Zen theme was the reason. With my own Stark based theme it works like it's supposed to.

  • Your code seems fine see here: drupal.org/node/1059636 did you cleared the cache ? Sep 27, 2013 at 12:47
  • Clearing the cache didn't help. I don't get anything displayed. Hm...
    – horace
    Sep 27, 2013 at 13:50
  • The code should work fine. Did you check Manage Display settings in Your content type ? Make it visible in Full and teaser mode. Sep 27, 2013 at 14:52

1 Answer 1


This is a perfect use case for the Field Formatter CSS Class module.

After adding a text list, radio, or taxonomy field to a content type, you then put the field on the view mode you would like for the class to be on. Use the CSS Class formatter and what level you would like to apply the class (generally node is fine), then you can add your CSS rules for whatever you want.

For example, you can change the individual caption background color on slides in a rotator, or specific stylings per post in a blog feed.

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.