[kupu-dev] RichText image captions
Duncan Booth
duncan.booth at suttoncourtenay.org.uk
Wed Apr 16 16:19:29 CEST 2008
"David Siedband" <siebo.lists at gmail.com> wrote:
> I'm trying to understand how image captioning works in Kupu and
> implement RichText captions for one of my clients.
>
> It looks like captions are applied by some sort of transform based on
> the description element of the image. I found
> kupu/plone/html2captioned.py and I'm slowly wrapping my head around
> it...
>
> 1) What do I have to do to my custom-types to make their RichText
> fields able to embed images with with captioning? It seems that this
> doesn't work on all RichText fields
>
> 2) I have a custom image type that has a RichText body field in
> addition to description. I think I could achieve this by creating a
> new transform similar to html2captioned.py and but configured to pull
> the caption from my custom RichText fields on the images. Does that
> sounds like a sane approach?
>
Did you also find kupu_captioned_image.pt? It seems to me that would be
the place to modify things rather than creating a new transform. In the
template options/fullimage should be the object, so if your custom type
has some custom field e.g. richcaption then change the captioning
expression to something like:
tal:content="options/fullimage/getRichcaption|options/caption|nothing"
and that ought to do it. Actually it looks like that should preserve
structure: options/caption is already html quoted.
I don't think I documented all the values passed to that template in
options. They are:
class (class attribute from the pre-transform html)
originalwidth (width attribute from the pre-transform html)
originalalt (alt attribute from the pre-transform html)
url_path (base relative url of the object)
caption (object description with newlines converted to <br>)
image (the scaled image)
fullimage (the original unscaled image)
tag (tag for the scaled image)
isfullsize (True iff image is fullimage)
width (width of the scaled image)
More information about the kupu-dev
mailing list