Leadimage from internal images or first image in text body

The LeadImage behavior provides a mechanism to upload and image as part of an object.
I would like to set the LeadImage from an existing image (already available on the site)
or from some automatic behavior that would use the first image in the text body.

Is it possible?

I have had a stab at creating collective.behavior.relatedteaserimage but it is in a "works for me" state. Will create a repo on Github shortly. You can take a look there and see if my approach "works for you" :wink:

repo link: https://github.com/mtrebron/collective.behavior.relatedteaserimage

The behavior will add a new field to selected content types, e.g.


1 Like

It's a good start, but I want this image to behave just like a ordinary leadimage (so it shows anywhere a leadimage is expected). An alternative mechanism would be to scan the text body to use the first image as the leadimage. I'll play with the code, thanks.

Have fun, see also these posts for reference: