0

I need add a class to a image for one specific views.
I tried:

  • theme_preprocess_field() but it doesn't work
  • theme_preprocess_image() but it's for all the images
  • I tried what suggested in Override image template for field image_formatter own, but it is too complex to simply add a CSS class
  • This answer is the more accepted but I like other ways

Is it possible to override a field/image template file for a specific view?

0

If your view is outputting fields (& not a teaser) you can easily do it in the views UI.

  1. Edit your view
  2. Click on the image field
  3. STYLE SETTINGS > Customize field HTML > Create a CSS class
  4. Save

Now your image field should have a class:

enter image description here

  • Just posted the same answer at the same time! (removed my one, it's ok) – David Thomas Oct 23 at 22:07
  • Great minds think alike, I guess, @DavidThomas – 100pic Oct 23 at 22:32
  • 1
    @100pic This option add the class to container of field not to the img tag. – Ruby232 Oct 24 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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