WordPress.org

Ready to get started?Download WordPress

Forums

Lightbox Plus ColorBox
Add custom link under image (2 posts)

  1. jumbo1
    Member
    Posted 9 months ago #

    Hello,

    I'm using Lightbox Plus with NextGen gallery.

    I'm looking to add a custom link under each image when lightbox opens (actually a link to a document associated with each image).

    Can you please tell me how I can do this?

    PS: In the NextGen database, I managed to associate each image with the document I want.

    Thank you

    http://wordpress.org/extend/plugins/lightbox-plus/

  2. jumbo1
    Member
    Posted 9 months ago #

    What I did so far (and it works) is:

    1- I added a "doc" attribute to the <a> tag of my image, so I get something like this with the name of the document I want to link to (taken from the nextgen database):

    <a rel="lightbox[set_1]" title="Picture1" href=".../wp-content/gallery/gallery1/pic1.jpg">

    2- I played with the code of jquery.colorbox.js to display my new "doc" attribute instead of the Title attribute, so I turned this:
    settings.title = settings.title || element.title

    Into this:
    settings.title = '<a class="doc" href="/wp-content/uploads/docs/'+$(element).attr('doc')+'">Download File'</a>';}

    And that's it! Under each picture, I get a link to the document associated with it.

    This is a dirty fix for me. If anyone has a better solution without removing the original title code, please tell me about it. I'm a total noob when it comes to javascript.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.