I am using Lightbox2 with cck image fields, directly and through views. In both cases the title attribute of the anchor tag is being filled with encoded markup and in the case of the cck image fields viewed as part of a node, the class tag is also being set as garbage.

This is an example of the code being created:

<a href="http://example.com/sites/all/files/headshots/image.jpg" rel="lightbox[field_headshot]" title="&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/node/1&quot; class=&quot;active&quot;&gt;&lt;/a&gt;">

When I give an image a title the the title attribute for the img tag is set and that overrides the title attribute in the anchor tag. But I have a lot of images with no title and so the garbage appears on mouse hovers.

CommentFileSizeAuthor
#4 lightbox2_5x_253959.patch923 bytesstella
#4 lightbox2_6x_253959.patch923 bytesstella

Comments

stella’s picture

Status: Active » Closed (works as designed)

This feature is by design and is the only approved way of displaying a link in the caption details area of the lightbox. As discussed in #253370: Configurable html in addition to caption? you will need to set the image title tag if you wish to avoid the html text being displayed when hovering over the image.

Cheers,
Stella

nasi’s picture

That makes sense as to why there is code in the title attribute, but in this case there is no caption, with or without a link, so is there any need for the code to be present at all in this instance? Could the title be left blank when there no caption to display?

Putting white space into the image title doesn't create a title attribute in the img tag to the only way currently to avoid the hover text is to manually enter text for every image.

stella’s picture

Status: Closed (works as designed) » Active

Would you mind trying the latest release? I think I've reproduced the issue but any patch I provide will be against the 5.x-2.6 release.

Cheers,
Stella

stella’s picture

Status: Active » Fixed
StatusFileSize
new923 bytes
new923 bytes

Try the attached patch against the latest versions of the module (5.x-2.6 or 6.x-1.6).

Cheers,
Stella

nasi’s picture

That patch seems to work (tested against 5.x-2.6). The title attribute in the anchor tag is now blank on my images.

Out of interest, there doesn't seem to be an option for automatically adding a caption to the lightbox, such as the image node title, or am I missing something? There is a 'Text for Image Page Link' setting on the Automatic Image Handling settings but that doesn't mention the use of tokens and implies that it will always be a link rather than a caption with no link.

Am I missing something obvious or is that facility only for when creating the lightbox links manually?

Cheers,
Stephen

stella’s picture

The automatic image handling options generally only refer to images where the rel attribute is added automatically by some javascript, e.g. to images in flickr blocks, image galleries, etc. It doesn't refer to imagefields in views as you can configure whether or not the lightbox should be triggered when editing the view / cck content type. IIRC, if you set a title for the image when uploading it, it should appear under the image in the lightbox. This can additionally have a link, if the "text for image link" is not blank.

Cheers,
Stella

nasi’s picture

I am using Imagefield Gallery module to integrate with Lightbox2 and that doesn't have any options for setting the title of the lightbox images. Having said that, their demo site does have titles in their lightbox, so I'm not sure what I'm doing differently.

Presumably that would be the point at which a caption should be generated and passed on to Lightbox2, rather than as a function of Lightbox itself?

stella’s picture

I'm not familiar with the Imagefield Gallery module, but the Imagefield module lets you set a title and alternative text, which the lightbox2 module uses as the caption. You should contact the Imagefield Gallery module maintainers to find out how to set a title when uploading your images.

Cheers,
Stella

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

stella’s picture

Released in Lightbox2 5.x-2.7 and 6.x-1.7.

Cheers,
Stella