Forum

Thread tagged as: Question, Gallery

Image html Alt tag

Hi,

I want to allow the user when posting an image to the gallery to allow them to input a html alt tag eg using a html editor rather than plain text.

At the moment the gallery album template code looks like this:

<a href="<perch:gallery id="main" />" class="gallery" title="<perch:gallery id="imageAlt" />" rel="album<perch:gallery id="albumID" />">
                <img src="<perch:gallery id="medium" />" width="<perch:gallery id="medium-w" />" height="<perch:gallery id="medium-h" />" alt="<perch:gallery id="imageAlt" />" />
            </a>
Michael Kashioulis

Michael Kashioulis 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hi Michael

The image tag alt attribute only accepts plain text - you can't include HTML within it.

Sorry drew I confused myself!!

What I meant was, when you upload a photo into the gallery you get the title box as shown here: https://img42.com/bdNrO

I want to be able to enter html into the title area so that I can produce hyperlinks when the lightbox pops up.

Hope that makes sense.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Add html="true" to the tag in the master template, and that should stop the HTML tags being encoded as text, leaving them as HTML.

Hi Drew,

Thanks for the reply. I dont want the client to have to manually input html but rather see the ck editor and use the WYSIWYG editor to add hyperlinks.

Thanks

Michael

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'll need to add a new field for that then. The title needs to be a text field.

Hi Drew

Sorry to be a pain!

So to get around the problem I've created a new text field in the c_list_image.html template (the template I'm using for my gallery) that pulls in the image description below the thumbail usng this code here: <p><perch:gallery id="desc"/></p>

in the image.html template I have my description field amended to allow html as below: <perch:gallery id="desc" type="textarea" label="Description" size="m" html="true" editor="ckeditor" />

When I save the image in the gallery all works well and the description is pulled in below the thumbnail but its all in plain html eg displaying as: <p><a href="https://www.google.com">testing</a> qqqqq</p> Rather than showing as the outputed html.

Any ideas why this is?

I have duplicated the code for the image.html and c_list_image.html into the master files too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Change this:

<p><perch:gallery id="desc"/></p>

to this:

<p><perch:gallery id="desc" type="texture" html="true" /></p>

Thanks drew, worked perfectly.

Mike