0

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:

alt="sketch2.jpg#asset:308

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?

user2569
  • 457
  • 2
  • 8

2 Answers2

2

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}) }}
carlcs
  • 36,220
  • 5
  • 62
  • 139
1

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.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143