WordPress.org

Ready to get started?Download WordPress

Forums

Add a class to an image (5 posts)

  1. manne80
    Member
    Posted 7 years ago #

    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?

  2. DE
    Member
    Posted 7 years ago #

    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 :)

  3. Joe Hall
    Member
    Posted 7 years ago #

    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.

  4. DE
    Member
    Posted 7 years ago #

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

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

  5. bhang
    Member
    Posted 6 years ago #

    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,

Topic Closed

This topic has been closed to new replies.

About this Topic