• Hi, I’m using thickbox on my blog. Everytime I insert an image to my blog I have to go into Code view mode and manually add the class=”thickbox”. Is there a way to ad the class=”thickbox” by default on every inserted image tags?

Viewing 4 replies - 1 through 4 (of 4 total)
  • you could do this with some javascript.
    Add some extra code to your thickbox library.
    Find out the name of the div where all your content with images is, and then run through the code and add a class “thickbox”.
    I use lightbox / prototype code so you might have to write it a little diffrent. I would probably come up with something like:

    mycontent = document.getElementById('Name if the div with your content');
    myimages = mycontent.getElementsByTagName('img');
    for (i<myimages.lenght){
    myimages[i].addClassName('thickbox');
    }

    didn’t have time to test the code, but if you understand what I’m saying I guess it’s engough to get you going ??

    Can I do the same thing to add a custom “rel” attribute for use with Lightbox 2? When using Lightbox 2 each thumbnail link requires rel="lightbox" Can I do something simular to get this done? A more detailed description of what i am talking about can be found here.

    guess something like
    myimages[i].rel=’lightbox’; should also work

    or you could save yourself the trouble and install
    a slimbox from https://www.inmypad.com/?p=100&cp=3

    im using thickbox..in what file exactly can i add this

    mycontent = document.getElementById('Name if the div with your content');
    myimages = mycontent.getElementsByTagName('img');
    for (i<myimages.lenght){
    myimages[i].addClassName('thickbox');
    }

    because i cant find it..

    thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add a class to an image’ is closed to new replies.