I have multiple views for the same content type (article), and want to override the Image Formatter template based on the view that is rendering it.

I have been able to add a suggestion to theme_suggestions_image_formatter_alter and select a template based on the content type and field name, based on the answer here, but if I apply that to the image field inside the article type, that applies to all views of this type. Is there any way to extract the view information inside the alter function so I can select the template based on the view as well as the content type?

  • You can use drupal.org/project/entity_view_mode to create different variation of node display and use it based on your requirements.
    – Ash U
    Mar 13, 2017 at 23:55
  • That project is only for Durpal 7, but it lead me to drupal.org/project/ds which looks promising, I'll give it a shot and see how it goes. Thanks.
    – joshhendo
    Mar 14, 2017 at 0:57
  • My bad, I thought you were using D7. Anyway DS should be able to handle this and much more.
    – Ash U
    Mar 14, 2017 at 1:01


Your Answer

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

Browse other questions tagged or ask your own question.