Docs

Full syntax

Bellow is the full syntax of ImageSwitch with its default value:

$.ImageSwitch({
	Type: "FadeIn", // Type of effect to run the function
	NewImage: "", //The new image will be loaded in
	EffectOriginal: true,
	Speed: 1000, //Speed of the effect
	StartLeft: 50, //The position the effect start compare to original position could be (-)
	StartTop: 0,
	StartOpacity: 0, //Which start opacity it would be
	EndLeft: -50, //The position the effect end compare to the original position could be (-)
	EndTop: 0,
	EndOpacity: 0, //Which start opacity it would be
	Direction: "RightLeft", //Which Way the image will be sroll
	Door1: "", //The image for the door 1
	Door2: "" //The image for the door 2
}, function);

Although it’s quite long, all the effect could work with only 2 settings: “Type” and “NewImage”.
You could still use it with only “NewImage” setting as ImageSwitch it will run “FadeIn” as default.

How to use the plugin

To use the plugin you will need to include jQuery javascript file which you could download at:http://jquery.com
Then include the plugin file download from the download section.
The full source is:

    
    

Then create an < IMG > object which will be used to load new image. Name it anything you want. I will name it: TestImg. We also need a button to trigger the effect. You could just make a link for it

	
	

Use the syntax ask in the example, the full code could be:

		$(document).ready({
			$("#TestTrigger").click(function(){
				$("#TestImg").ImageSwitch({NewImage:"image2"});
			});
		});

That’s it. Done for a simple ImageSwitch effect.

If you need any further help, you have an idea of new effect, you could give us a quick comment.

Share
April 20th, 2009

The code sample above is incorrect; It should read:
$(document).ready(function(){
$(“#TestTrigger”).click(function(){
$(“#TestImg”).ImageSwitch({NewImage:”image2″});
});
});

April 20th, 2009

*Julio Thank You. This worked perfect for me! :)

April 21st, 2009

Thank for pointing out, Julio. I fixed the code.

June 10th, 2009
Round-T

I’m trying to set up the Single Door effect on mouseover of the image, any pointers for setting up a mouseover event?

June 10th, 2009

Hi,
This link contain the guide of how to make the script fore mouseover effect with imageSwitch, hope it will help :)
http://www.hieu.co.uk/blog/index.php/2009/03/21/8-guides-to-apply-jquery-and-imageswitch-in-web-design/

June 10th, 2009
rv

hello,

I have 10 divs. Each div has its own image (with class=”select”), and its own button ( with class = “button”)

could i use this pluggin to implement:
everytime the botton of a particular div is clicked, ITS image is flied-out with direction of the button clicked? Also, i dont want the actual image to change. Just a fly-out effect added to it.
If so, how?

Thanks very much in advance!!!
rv
:)

July 8th, 2009
John

I love this but I cant get it to work at all in my html page. I have some small experience working with javascript but all I get when I try this is the first image on the page and when I click the image – nothing :(
Can anyone show me how this would look in a html code view
Thanks in advance!

August 9th, 2009

Hey,

Can I get this working with xml or json ? Thnx in advance!

August 18th, 2009
VAM

It would be cool to have a random setting for the type of transition, so it makes the images change with a different transition every time.

September 21st, 2009
Sortafreel

Hi. I too don’t unerstand how make it work.

Where I must poot this code?

$(document).ready({
$(“#TestTrigger”).click(function(){
$(“#TestImg”).ImageSwitch({NewImage:”image2″});
});
});

I am new to jQuerry, so it’s hard for me to understand.

September 27th, 2009

You should put this code in the end of the HTML file

October 4th, 2009
RandyG

Is there a simple way to get the transitions to initiate on page load? I want to use the imageswitch without using a button. Thanks!

October 6th, 2009

Hi, there isn’t a really simple way but there is way to do it. You could check out this post its contain almost everything you need to work with imageSwitch:
http://www.hieu.co.uk/blog/index.php/2009/03/21/8-guides-to-apply-jquery-and-imageswitch-in-web-design/

October 8th, 2009
seven_v

Hi,
I have a problem, the script works only in local server but uploading file on a web provider, it doesn’t work at all!
I’m sorry about my english, but I’m italian.
Could you help me please? :) )

October 8th, 2009

Hi seven_v,

There is a good chance that’s when u upload to server, the path to the javascript files could be different so it couldn’t load the javascript files.

Or you forgot to upload one of the javascript file (jquery.js, imageswitch.js)

As it’s only javascript, it doesn’t matter if it run on local server or run on a web provider.

If it still doesn’t work, you could just send me the code folder and I will check for you.

October 8th, 2009
seven_v

Hi HieuUK,
thanks!! I’m not sure to understand the meaning of your first sentence,
what can I do to bypass the problem you suppose to be (I mean the problem about the path to the javascript)??
thank you!! :) )

V.

October 8th, 2009
seven_v

I have found the solution!!! :) ))
It didn’t work because Linux is case sensitive and I need to put a ‘Q’ instead of a lowercase ‘q’ on jquery.js file, because in html I have:

Now it works!!!
thank you!

Valentina

October 28th, 2009
Chris

Hi.

Is it possible to get the same effect when changing the background image of DIV and not the src of an image?

Thanks.

October 28th, 2009
Chris

Nevermind, I managed.

I created my “own” animation, FlyBG, exactly like the FlyIn and added the change of the bg url:

$(‘#divChris’).css(‘background-image’,'url(http://www.myimage.com/image.jpg)’);

I then used http://www.evanbot.com/article/jquery-delay-plugin/4 to delay the change of the image until the animation completes.

Cheers.

March 2nd, 2010

Thanks, the plugin is very useful.

One issue, though – ImageAnimating() always returns false for the “FadeIn” animation, because the data(“imageswap”) is never set. This also causes ImageStop() to fail.

March 10th, 2010
emailandthings

Does it work with jquery 1.4+?

April 30th, 2010
Ildiko Toth

Hi,

My problem is that, if I use a width or height on the images , the the Imageswitch open it at first in an original size, and then will be a defined size. Do you have an idea how can I resolve this problem?

Example:

Simple image gallery

Play slide show

July 29th, 2010

Julio!
Just delete and write again the quotation marks.
Great slider!:D

September 18th, 2010
Blunty

Hello and congratulations for this fine work.

I am not very strong in jquery and I wonder if it is possible to do that every single animated images without having to click on an effect?

Thank you

September 28th, 2010
Lefataliste

Hi there!

Anyone knows how to use this wonderful plug-in to create interactive maps

(img hot spots that activate an effect) if is possibile?

Thanks!
F,

October 28th, 2010
Rob

Does this code work for linking the image to a page?

November 26th, 2010
Greg

Can you update the example code:

FROM
$(document).ready({

TO
$(document).ready( function () {

December 11th, 2010
Hiren

What to do for automatic image sliding with different effects?

January 16th, 2011
eric de wilde

Hi,

My basic javascript code that puts an image-object in an empty div on the ‘onclick’ event :

var vFotodiv = document.createElement(“DIV”);
vFotodiv.id = “Fotodiv1″;
vFotodiv.onclick = fShowImage;

function fShowImage() {
vSelected = window.event.srcElement;
var vImg = new Image();
vImg.src = “foto.jpg”;
vSelected.appendChild(vImg);
}

this works fine, but i can’t figure out how to implement one of the imageswitch effect in this code.
Would be very nice if one of these effect appears when the image comes into the div.

Could someone help me on this please…
thx

February 3rd, 2011
ikary

nice try, but is slightly usable

- you should expect that the image is fully loaded before starting FadeIn
- you should add the effect of “loading”with a spinner or similar
- you should avoid running other FadeIn while the former
- you should avoid doing the exchange on the same image

February 4th, 2011

Is there a way to make it auto rotate without having to click?

March 17th, 2011
Christian

Why didn’t upload a zip example? It’s complicated to deploy it for a novice.
Thanks.

March 17th, 2011

Trying to install this on my website, but having some difficulty. A zip file with demo html would be much help.

March 30th, 2011
aco

Yes, a ZIP will be great!

April 12th, 2011

Throughout New York, London, milan and Paris fashion week.

May 15th, 2011
andy

Thanks, I was trying to do this manually but your solution worked great!

May 19th, 2011

Very strange. All scripts work perfect on my localhost, but when I upload them to remote server they don’t.
Do you know why?

June 16th, 2011

It’s a very nice Slider.

It’s working for me very well with jquery.1.4 version

I try many slider in same page, and it’s working very well

thanks again

June 22nd, 2011
Thirdian

Hi HieuUK. Thanks for great script. But I have a problem. Script, doesn’t work with jquery v1.4.2. Can’t understand why.

June 22nd, 2011

Great slider. Best I’ve seen so far and that’s saying a lot. I’ve seen my fair share of sliders.

July 15th, 2011

Hi I am really trying to utilize this Image Switch in HTML is that possible? I am familar how to make stylistic change….but can never seem to get the item activated…..

how do I link the pages..I use coda….

My questions would be…

1. Where exactly to put each code..
a. ex. I know about putting the stuff in head section but do i make title changes to make it specific for my page?
b. when I put the .JS into my root…do I need to re-title it?
c. how do I link it all together…

2. how and where do I save images files to be called on.
3. how do I call to images?? IDK maybe if I sent the code you could mark it up and show me what you did or something I would really really like to learn how to use these JS sliders and stuff PLEASE HELP

thank you so much for any help

September 10th, 2011

Its interesting. I would like to know more about this…I really wanted to know how this works can you please help me out…….Thanks for sharing. HER3W

September 30th, 2011

This slider is so sweet. Wondering why I haven’t seen it around the web a lot.

December 16th, 2011
Cha

You said to put this code at “the end of the HTML file?” Just like this? Cause it ain’t working, so maybe there’s something else you didn’t mention?

$(document).ready({
$(“#TestTrigger”).click(function(){
$(“#TestImg”).ImageSwitch({NewImage:”image2″});
});
});

So I’ve spent an hour or more trying to figure this out, and the last comment from the author is two years ago. So I guess this was a waste of my time.

January 31st, 2012
nate

cha the code you have above is incorrect. Try

$(document).ready(function(){
$(“#TestTrigger”).click(function(){
$(“#TestImg”).ImageSwitch({NewImage:”image2″});
});
});

February 1st, 2012
ksj_23

ImageSwitch( {…}, function) <–what does the 'function' mean ?

Leave a Reply