0

What name do I have to give to my image.html.twig so the template only being used in content type "project" because I need to add class to an <img> tag. I already tried

  • image--node--field-afbeeldingen--project.html.twig
  • image--node--field-afbeeldingen.html.twig

1 Answer 1

0

I'm not sure about overriding the <img> tag itself, but for your approach I would recommend overriding the field template. Assuming your field is named field_afbeeldingen, you can create a template called field--field-afbeeldingen.html.twig.

Within there, you could manually render your <img> tag as needed, with whatever additional classes required.

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.