When I add an image via a rich text (doing as port of a flexi layout approach) somehow an alt tag gets auto output, e.g:


I wondered if there is a way to over ride or edit the HTML via the rich text field for the auto generated alt tag?

  • Just click the Rich Text field's HTML button and change it to whatever you want? – Brad Bell Dec 21 '16 at 22:03
  • thats the one, thanks tried earlier I thought but must have mucked up good to go now – user2569 Dec 21 '16 at 22:18
  • Cool... I'll add that as an answer. – Brad Bell Dec 21 '16 at 22:19

The Retcon plugin works great for DOM manipulation. You can override the attribute with a default value or remove it completely.

{{ entry.body|retconAttr('img', {'alt': entry.title}) }}
{{ entry.body|retconAttr('img', {'alt': false}) }}
  • Of course you've got the better answer. :) – Brad Bell Dec 21 '16 at 23:07

Assuming you've got the "source" plugin defined in your craft/config/redactor/myconfig.json Redactor config for that Rich Text field's settings, you can click on the "HTML" button and edit the alt tag manually to whatever you wish.

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.