I'm wondering if it's possible to add labels to images within a rich text field. I'm able to apply a label to an image, but when I save and publish the document, the label disappears. Am I missing something on how to do this? What I'm trying to achieve is the ability to add classes to images within rich text so that they can align left or right, 50% width or full - is there a different way to achieve this?
In the meantime, I’ve achieved this by using slices to add multiple rich text areas that have a group of repeatable images with options for formatting. I still think it would be ideal to be able to apply labels to images in rich text though, as this seems like a bug at the moment.
No, it's not possible to add labels to image fields in the rich text field. This is not something that will be re-implemented as it goes against the recommended workflow of using Slices described here.
What will happen is that we will properly deprecate it by removing labels from being selectable when an image is highlighted as this causes confusion and gives the impression that labels can be applied, though as you’ve seen they cannot.
The recommended way of creating a page layout such as this is using slices. This works even better with Slices labels.
Another slightly different way to model your content like this is to have different slices for different text presentation.
For example, you would have:
1x [Full-width text block] 1 x [Text and image block with Slice label to set image alignment]
Then with these 2 Slices, you can build dynamic pages easily, like so:
[Full-width text block]
[Text and image right]
[Full-width text block]
[Text and image left]
Let me know if this makes sense or if you need a more solid example.
Hi @Phil - is this a new change that you’re not able to add labels to images embedded in rich text? I’m certain that we’ve been able to add them to images in the past, and we had set up labels specifically for images (like float-left, float-right, img-fluid, etc.) so that we can handle embedding images with text wrapping around them.
Since it’s possible to add a label directly onto an image in the editor, it seems like this should be an available feature and that there’s just a bug preventing the label from saving with the image?
This is not a new change no. The only thing the rich text labels do is wrap a selection of text in a <span> tag and give it a class name, this is applied in the HTML Serializer. So I don’t think this would be useful for setting the image class, but it’s something I have to explore.
Maybe this is something that was configured in your project with Slice labels like I described above? This is what we recommend.