6

I am trying to use a jQuery lightBox implementation on my website that is generated from reStructuredText. The lightBox takes the title of the link around the images as the caption of the image in the lightBox display.

However, I can't seem to find a way in reStructuredText of providing a title attribute on a link - does anyone know of a way of doing this? My images are defined like so:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image001.jpg

So I can add an alt attribute, but not a title. A possible alternative may be to use a target as the reference like so:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image1_

.. _image1: image001.jpg

In this latter case, I am not sure how to add attributes to the link defined at the bottom (if it is possible at all).

Chris
  • 44,602
  • 16
  • 137
  • 156
Anthony Roy
  • 1,835
  • 3
  • 15
  • 16

1 Answers1

0

I assume (try it out!), the title attribute is no longer needed by lightbox after lightbox is initialized. So if you'd like to provide the images alt-attributes as title, this one should do so, if you call it after lightbox-initialization:

function alt_2_title () {
    $("img[alt]").each(function(){
        $(this).attr('title', $(this).attr('alt'));
    });
});

This copies alt to title for every image that has an alt-attribute; If you like to modify only a few images, you might restrict you images selection by using something like ...

function alt_2_title (name_of_container) {
    $("img[alt]", "#"+name_of_container).each(function(){
        $(this).attr('title', $(this).attr('alt'));
    });
});
HBublitz
  • 670
  • 4
  • 6
  • 3
    Apart from jQuery and lightbox I would like to know how to do what the OP asked. Not copying alt to title, just being able to set the title as well as alt. – helderco Oct 12 '13 at 15:08