2

All of my assets have fields for alt text and I understand how to access that info from an asset field, but can not figure out how to do it when an image has been inserted using Redactor.

Any help will be much appreciated!

  • If you haven't already, I would recommend taking a look into Matrix fields: buildwithcraft.com/features/matrix. This would allow you to create your own custom content blocks (text, image etc), and assign fields to these. So you can create an image block, and in there have a plain text field that sets the alt tag for the image. – Jamie Wade Nov 18 '14 at 9:28
3

For alt tag content you can just click the image in the richtext field, hit the 'edit' button and add a title.

As far as I know there is no way to integrate an alt text field (or any other fields) from assets without writing a custom redactor plugin. I posted a similar question here and the only solution was to use a matrix field instead. But I too would love to hear about any other options.

| improve this answer | |
1

I think you simply can't set it from the redactor editor. But because asset meta fields are saved "globally" and not "per entry", you can enter the content from the CP's assets section.

But that probably won't help you much, because there's no out-of-box solution to output the fields data in your template. You would need to extent Redactor with a plugin and I'm not sure if you can modify how images are handled.

But like Douglas said, the best solution around this is to use Matrix instead.

| improve this answer | |
  • Thanks, but Matrix is not really a good solution here because I want to be able to add any number of images in various places within the text body. – Roi Agneta Nov 19 '14 at 17:31
  • Why do you think Matrix doesn't allow you to do that? Just add one "Text" block with a Redactor field and one "Images" block with an assets field. Start writing with a "Text" block and stop at that position of your article where you want one or multiple images to be and add a new "images" block. Then add another "Text" block to continue writing, @RoiAgneta! – carlcs Nov 19 '14 at 17:40
  • That's just the basic version, but you could add fields to your "Images" to change size, position etc. of that block's images. Or add another block type for "Quotes" for example. – carlcs Nov 19 '14 at 17:44

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.