Stacker-flow
Stacker-flow

Reputation: 1309

Getting a jquery lightbox to pull the image out of a <img> tag

On my website I am currently using a jquery plugin that scrolls images automatically across the page, which is all fine.

But if you click the image it just takes you to the image source and I want to use a lightbox feature incorporated with it. The problem is all the jquery lightbox codes I can find uses a href tag to get the image url, but the scroller uses img as so;

img src="img/img1.jpg" longdesc="img/img1.jpg" width="400" alt="Image 1" /

how can I get around this?

Upvotes: 0

Views: 1531

Answers (2)

Fresheyeball
Fresheyeball

Reputation: 30015

First thing you are going to need to do is to disable the onclick behavior of Image flow: http://finnrudolph.de/ImageFlow/Documentation Luckily its available in the image flow options.

Something like onClick : $.noop

Next you need to make some alterations for your lightbox. Colorbox uses the href attribute to determine what content to display. Its not standard but you should be able to get away with an href attribute on an image element. Give it a shot.

<img src="img/img1.jpg" href="img/img1.jpg" width="400" alt="Image 1" />

Upvotes: 1

John Smith
John Smith

Reputation: 81

You can select the attribute of the img element by using "document.getElementById("id").src" or "document.getElementByTagName("img").src" in JavaScript and then assign that to a another tag the same way, just changing the "id" to the correct id and the "src" to whatever the attribute is.

Upvotes: 0

Related Questions