Forums / Cotonti / Support / Extrafield Textarea for some reason modifies the uploaded content

staleo
#1 2013-10-13 19:38

All right, the topic is far from being easily understandable from the first sight, but let me explain.

For a better picture-sliding performance on a page, I use a great JQuery-run gallery by Artem Polikarpov, called Fotorama. Here's it: http://fotorama.io.

Among the options it offers, there's an easy way to add a caption for a specific image. Here's how it works. You just need to implement a parameter

data-caption="blabla"

Like here: 

<div class="fotorama">
 <img src="1.jpg" data-caption="One">
 <img src="2.jpg" data-caption="Two">
 <img src="3.jpg" data-caption="Three">
</div>

where One, Two, and Three are the captions for the photos you want to insert. I need to fulfill the images dinamically, so I implied an extrafield textarea. But here is a puzzling thing: Cotonti erases (!!) the data-caption="One" parameter, and instead, adds a alt="1.jpg" parameter. I got nothing against the alt thing, but where's my data-caption?

Hope to find a good solution with you.

BTW, you guys should really check this Fotorama thing, it really kicks asses!

Twiebie
#2 2013-10-13 20:08

Hi staleo,

It's most likely HTML Purifier filtering the data-caption attributes.

Try adding this to /plugins/htmlpurifier/presets/htmlpurifier.group_5.preset

$def = $config->getHTMLDefinition(true);
$def->addAttribute('img', 'data-caption', 'Text');
staleo
#3 2013-10-14 05:33

Seems to work correctly now, I appreciate it, Twiebie!