for your specific problem, if you are generating XML with a <picture>
tag, I think you are creating a new output mime-type. it's no longer text/html
.
plone.outputfilters
and it's resolve_uid_and_caption
could get a new transform from x-html-safe
to text/my-new-mimetype
that does this magic for you.
See Plone Outputfilters and TransformChain (how to display things differently) I should upload those slides somewhere I guess.
I do something similar to make google amp replies use <amp-img>
tag instead of <img>
we have a collection of image templates we use, and simply register them with zcml. We switch between them using layers or output mimetypes.
<browser:page
name="plone.outputfilters_captioned_image"
for="*"
class=".captioned_image.CaptionedImageView"
template="captioned_image.pt"
permission="zope.Public"
layer="rfasite.basetheme.interfaces.IRFASpecific"
/>
Note how our image tags change when you request
https://www.rfa.org/english/news/myanmar/burnings-03092022193907.html
verses
https://www.rfa.org/english/news/myanmar/burnings-03092022193907.html/ampRFA
I think your problem is very similar, but much more verbose.
Caution: Opinions.
I really hate that most of the really cool html-image transforms are happening on the field level using plone.outputfilters
and not so much has been built into portal_transforms
.
But I do understand that the output mime-type of a field could be different than the output mime-type of a HTTP reply. I just wish I could use the power of output filters on the entire response instead of just a single field.
The solution may also be too tightly coupled to TinyMCE - but I'm not sure. I don't use other wisiwig editors and haven't run into the problem.
I really think that some of the problems could be solved better using the .tag()
method found on OFS.Image . I've always hated that deep-down, the tag() method returned HTML that was hard-coded into python. I want to be able to customize the output of '.tag()' as flexible as how output-filters does it.
Deep, deep down, I think that 'image.tag()' is bad anyway, as it is too tightly coupled between the object and it's representation, but I've been told it's convenient syntax.... which is a horrible excuse.
So anyway, yeah.