JavaScript - Image Gallery Link To Image File
So I have a gallery which is displaying images from an array called imgList. When they are displayed I want the user to be able to link directly to the image. Is there a simple way to do this?
The JavaScript: Code: //<!-- var imgList = new Array( "images/gallery/1.jpg", "images/gallery/2.jpg", "images/gallery/3.jpg", "images/gallery/5.jpg", "images/gallery/6.jpg", "images/gallery/duo.jpg" ); var clientData = new Array( '', '', '', '', '', '', '' ); var currentMain = 0; var currentMainT = 0; var current_position=0; var all_links=""; function init(){ all_links=document.getElementById('gallery').getElementsByTagName('a'); all_links[0].style.color="#7d3d3d"; ShowMain(current_position); } function color_me(element,color){ element.style.color=color; } function Prev(){ color_me(all_links[current_position],'#000000'); if((current_position-1)>-1){ current_position=current_position-1; } else{ current_position=(all_links.length-1); } ShowMain(current_position); // ShowMainT(current_position); color_me(all_links[current_position],'#7d3d3d'); } function direct_selection(number){ all_links[current_position].style.color="#000000"; current_position=number; ShowMain(current_position); all_links[current_position].style.color="#7d3d3d"; } function Next() { color_me(all_links[current_position],'#000000'); if((current_position+1)<all_links.length){ current_position++; } else{ current_position=0; } ShowMain(current_position); // ShowMainT(current_position); color_me(all_links[current_position],'#7d3d3d'); } function ShowMain(which){ currentMain = which; currentMainT = which; if ( currentMain < 0 ) currentMain = 0; if ( currentMainT < 0 ) currentMainT = 0; if ( currentMain > imgList.length-1) currentMain = imgList.length-1; if ( currentMainT > clientData.length-1) currentMainT = clientData.length-1; document.getElementById('mainImg').src = imgList[currentMain]; document.getElementById('mainText').innerHTML = clientData[currentMainT]; var PD = document.getElementById('Pg'); var PD2 = document.getElementById('Pg2'); document.getElementById("mainText").style.display = 'inline'; // return false; } onload = function() { ShowMain(0); } onload = function() { ShowMainT(0); } //--> //<!-- function preloader(){ // counter var i = 0; // create object imageObj = new Image(); // set image list images = new Array(); images[0]="images/gallery/1.jpg"; images[1]="images/gallery/2.jpg"; images[2]="images/gallery/3.jpg"; images[3]="images/gallery/5.jpg"; images[4]="images/gallery/6.jpg"; images[5]="images/gallery/duo.jpg"; // start preloading for(i=0; i<=3; i++){ imageObj.src=images[i]; } } //--> The HTML where it is displayed: Code: <img id="mainImg" src="images/gallery/1.jpg" style=" border: solid #7d3d3d 5px;" alt="galleryimage" /> Similar TutorialsI have almost 300 photos that I want to have in a gallery that is easy to use. I would like to avoid making 300 list items (as is necessary with all of the auto rotators and other jquery plug ins that I've found) but to have the images load straight from the folder after the rest of the website has loaded. It wold be nice if maybe there was a pretty horizontal scroll bar or something and the image in the middle of the page was biggest if possible, but I'm really not picky. I don't know what the best way is to display so many photos! They don't need captions or anything. Any ideas??? Thanks! Hello, I am working on a page that has a jQuery full browser BG image and I am trying to also utilize a MooTools gallery. There seems to be some interference between the two JavaScripts as only one works (whichever one is last in order in the header of the HTML document). Links: http://www.courtneyhunt.com.au/press_bg.html http://www.courtneyhunt.com.au/press_gallery.html I am a complete novice with JavaScript so if anyone could help that would be great. Thank you in advance. Hello, My site has an image gallery with a row of pictures at the bottom. When I load up the page it should show image 1 in the main gallery window, but instead it's showing image in position #10 (the one to the left of #1). You can see what I'm talking about here. When you load the page it's showing the White House, but it should be showing the Green House (position #1 in slider). The White House can't be seen in the slider since it's in position #10, but shows up first int the main window. Is this a javascript issue or what? All JS files can be found here Can anybody help me debug this?? I'm going nuts Thank you Hi guys. I wanted to show you a gallery that I am doing. I'm stuck here with some issue. I've made the gallery with the buttons but now I wanted to add a previous and next button but I not being able to do. all the rest is working. the javascript code is this: Code: $(function () { var imgContainers = $('div.tabs > div'); imgContainers.hide().filter(':first').show(); $('div.tabs ul.number_nav a').click(function () { imgContainers.hide(); imgContainers.filter(this.hash).show(); $('div.tabs ul.number_nav a').removeClass('selected'); $(this).addClass('selected'); return false; }).filter(':first').click(); }); the html file is this: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>gallery</title> <!--CSS--> <link href="style.css" rel="stylesheet" type="text/css" /> <!--JavaScript--> <script type="text/javascript" src="jquery-1.4.2.js"></script> <script type="text/javascript" src="code.js"></script> </head> <body> <div id="gallery"><!--IMG CONTAINER START --> <div class="tabs"> <div id="image_01"> <div class="image"> <img src="image_one.png" width="795" height="395" /> </div> </div> <div id="image_02" > <div class="image"> <img src="image_two.png" width="795" height="395" /> </div> </div> <div id="image_03"> <div class="image"> <img src="and_so_on.png" width="795" height="395" /> </div> </div> <ul class="number_nav"> <li><a href="#image_01">01</a></li> <li><a href="#image_02">02</a></li> <li><a href="#image_03">03</a></li> </ul> <ul class="prev_next_nav"> <li><a href="#">Previous</a></li> / <li><a href="#">Next</a></li> </ul> </div> </div> </body> </html> here is the zip file: http://www.sendspace.com/file/we3lkd can someone help me to make the code to the previous / next code please? I'm not very good ( nothing at all ) with javascript... Hi I want to create an image gallery which has one main image (large size) with a series of smaller thumbnail images below. When you click on one of the smaller images below, I need it to load it into the space above. This series of images will be selected by a PHP script and a MySQL database. The ratios of the images will not always be the same, so the boundry box will need to change width and height accordingly. This will change the height of the page too I guess. Now, the real fly in the ointment is that I really would like the main image to have a drop shadow (gradient based) on all 4 sides of the image. So, good people of the JS Sub-Forum - whats the best way to get this done?! Cheers The Moose Hey all, I'm designing a website and i'm doing a section on a portfolio of artwork. wat i would like is to group the work under different headings and for each group to have a thumbnail of an image. when that image is clicked a window is opened which displays all the works in that group as thumbnails as well as an image gallery (larger image of the current image and being able to click on the other thumbnails to view a larger image of it). hope that makes sense. I've been searching all over for scripts bit nothing fits my criteria exactly. going a bit crazy over this, any help or direction much appreciated. peace Does anyone know of a good webscript slideshow on a loop that I can use in a website ? www.chagfordshow.com We don’t want a database at the moment. Needs to work in all browsers. What I’m looking for :- Change the image every few seconds. Slip into any element of the webpage. All images will be the same size. Some landscape, some portrait. Looking for this to work all in client’s scripting. or maybe AJAX Thanks. Most grateful if anyone can help Hello. I am having trouble with a simple image gallery with navigational buttons including "first", "next", "previous", and "last"; and making a drop-down archive menu. 1. For the most part, the image gallery works. The problem is that when a user clicks on "next", and then "prev", the last image is not displayed. On the other hand, if a user clicks "prev", and then "next" the last image is displayed(works normally). 2. The way I am displaying the last image, the function last(), is not efficient. It simply refreshes the page in order to display the last image. Basic overview: The images follow a simple standard: page1, page2, page3,...page64; they are in a subfolder "img". The function changeImage() changes the image from the prev, to the next. The image gallery displays the last image in the gallery; when a user clicks on 'prev' it goes to the previous image, and go to the next image when clicked on 'next'. If the current image is the last image, and the user clicks on 'next', it goes to the very first image. Here is the code (in the <HEAD> tags): Code: <script language="JavaScript"><!-- which_image_loaded = -1; NUMBER_OF_IMAGES = 64; current_comic = 0; ImageNames = new Array; ImageNames.length = NUMBER_OF_IMAGES - 1; for (counter = 0; counter < NUMBER_OF_IMAGES; counter++){ file_number = counter + 1; filename = ("../img/page" + file_number + ".png"); ImageNames[counter] = filename; } function changeImage(direction) { which_image_loaded += direction; current_comic = which_image_loaded + 1; if (which_image_loaded < 0) which_image_loaded = NUMBER_OF_IMAGES - 1; if (which_image_loaded == NUMBER_OF_IMAGES) which_image_loaded = 0; if(current_comic <= 0){ which_image_loaded--; } document.myimage.src = ImageNames[which_image_loaded]; } function first(){ which_image_loaded = 0; current_comic = 1; document.myimage.src = ImageNames[0]; } function last(){ window.location='http://www.bearoncampus.com'; } and in the <BODY> tags Code: <img src="img/page64.png" alt="New comic not available." name="myimage" width="725" height="275"> <form> <input type="button" value="FIRST" onClick="first()"/> <input type="button" value="PREV" onClick='changeImage(-1);' /> <input type="button" value="NEXT" onClick='changeImage(1);' /> <input type="button" value="LAST" onclick="last()" /> </form> My guess is the code is not working properly due to the initial values of the counter. Last, is there a way to display the current image "myimage.src" using a dropdown menu with each option value as each image? I have done this with window.location, but this only redirects to the image location. Much thanks. Any help is greatly appreciated. Not sure where to even start here. I am trying to build a a small JavaScript image gallery. As you can see in the jpeg image at the link provided, i want the user to be able to change the large image by clicking on the small thumbnails. The thumbnails will also have a roll over where they enlarge slightly. Complicated? I'm not a javascript expert, but i know enough by editing existing code and have saved a bunch of code i've modified. I've googled for javascript image galleries and looked through them but no success... I can understand the clicking on a thumbnail to change the larger image but what gets me is having the thumbnail on top of the larger..as well having a still image at the top left....some sorta layering? anyway some sorta help to get me started would be very helpful... http://www.rossow-web.com/test/RCC_Mockup.jpg thanks! Hello, Do you know any HTML/Javascript/JQuery photo gallery which behave like this flash gallery? http://www.erwinolaf.com/#/portfolio..._2001/gallery/ The point is images : 1- Images does not show in a modal popup window. 2- When each thumbnail selected , current image animate to left and selected image also shown with comming from right to left. Thanks Mazdak I'm making my first venture into Javascript with this project. i've been successful so far, but i'm trying to add a few more elements and i'm not sure how to do it. here's the test site: http://www.ductaman.com/test1/amenities.html there's a few ways i want to go from here, one is to add captions to each picture when it's made large. the other is to maybe have the thumb link to another photo, that way i can make the thumb be a face, and have the large pic be their whole body. etc. i was hoping i could do this by adding more variables to the "a_load()" function. So i guess i was wondering if i can draw on a variable defined by "a_load()" with "b_load()" and if so, how? i have made several educated guesses as to how i would do this, but nothing has worked. thanks -Andy head code: Code: <script type="text/javascript"> function a_load(a_pic1,a_file1,a_pic2,a_file2,a_pic3,a_file3,a_pic4,a_file4,a_pic5,a_file5,a_pic6,a_file6) { document.getElementById(a_pic1).src = a_file1; document.getElementById(a_pic2).src = a_file2; document.getElementById(a_pic3).src = a_file3; document.getElementById(a_pic4).src = a_file4; document.getElementById(a_pic5).src = a_file5; document.getElementById(a_pic6).src = a_file6; } function b_load(whichpic) { var x=document.getElementById(whichpic); document.getElementById("largepic").src = x.src; } </script> body code: Code: <div id="map"> <img src="images/default/chevy.png" id="chevy" onclick="a_load('pic1','images/default/lion.jpg','pic2','images/default/chimp.jpg','pic3','images/default/zebra.jpg','pic4','images/default/fish.jpg','pic5','images/default/cat.jpg','pic6','images/default/dog.jpg')"> <img src="images/default/ford.png" id="ford" onclick="a_load('pic1','images/default/cow.jpg','pic2','images/default/duck.jpg','pic3','images/default/fish.jpg','pic4','images/default/frog.jpg','pic5','images/default/eagle.jpg','pic6','images/default/cat.jpg')"> <img src="images/default/honda.png" id="honda" onclick="a_load('pic1','images/default/chimp.jpg','pic2','images/default/zebra.jpg','pic3','images/default/cat.jpg','pic4','images/default/lion.jpg','pic5','images/default/frog.jpg','pic6','images/default/duck.jpg')"> <img src="images/default/toyota.png" id="toyota" onclick="a_load('pic1','images/default/dog.jpg','pic2','images/default/fish.jpg','pic3','images/default/cat.jpg','pic4','images/default/eagle.jpg','pic5','images/default/zebra.jpg','pic6','images/default/lion.jpg')"> <img src="images/default/nissan.png" id="nissan" onclick="a_load('pic1','images/default/frog.jpg','pic2','images/default/lion.jpg','pic3','images/default/fish.jpg','pic4','images/default/dog.jpg','pic5','images/default/chimp.jpg','pic6','images/default/zebra.jpg')"> </div> <div id="gallery"> <img src="images/default/cat.jpg" id="pic1" height="150" width="200" onclick="b_load('pic1')"> <img src="images/default/dog.jpg" id="pic2" height="150" width="200" onclick="b_load('pic2')"> <img src="images/default/duck.jpg" id="pic3" height="150" width="200" onclick="b_load('pic3')"> <img src="images/default/chimp.jpg" id="pic4" height="150" width="200" onclick="b_load('pic4')"> <img src="images/default/eagle.jpg" id="pic5" height="150" width="200" onclick="b_load('pic5')"> <img src="images/default/frog.jpg" id="pic6" height="150" width="200" onclick="b_load('pic6')"> <div id="mainpic"> <img src="images/default/cat.jpg" id="largepic" height="300" width="400"> </div> </div> </div> I'm totally stumped. Check this out: http://174.37.72.84/portfolios/engagements/ It works in FF and Safari, but not IE. Everything validates, and I'm getting no JS errors. Anybody have any ideas? Thanks First off, Hello, I plan to be frequenting these forums as I am still learning JavaScript. I am creating a gallery and am having trouble getting the previous and next buttons to work properly with the current image. I was trying to create a solution that would change the current image variable so that the previous and next buttons would correlate. What I am working on can be found here. As you can see the next and previous buttons are not working. Here is my JavaScript: Quote: <script type="text/javascript"> /* following not currently used by this script function show(what) { var find = "Img" + what.id.substring(4); for ( var i = 1; i < 99999; ++i ) { var cur = "Img" + i; var img = document.getElementById(cur); if ( img == null ) return; img.style.display = ( find == cur ) ? "block" : "none"; } } */ var Pg = 0; function Prev() { Pg--; if (Pg < 0) { Pg = 0; } document.getElementById('mainImg').src = imgList[Pg]; document.getElementById('Pg').innerHTML = 'Image '+(Pg+1)+' of '+imgList.length; } function Next() { Pg++; if (Pg >= (imgList.length-1)) { Pg = imgList.length-1; } document.getElementById('mainImg').src = imgList[Pg]; document.getElementById('Pg').innerHTML = 'Image '+(Pg+1)+' of '+imgList.length; } function Pick0() { var Pg = 0; document.getElementById('mainImg').src = imgList[Pg]; } function Pick1() { var Pg = 1; document.getElementById('mainImg').src = imgList[Pg]; } function Pick2() { var Pg = 2; document.getElementById('mainImg').src = imgList[Pg]; } function Pick3() { var Pg = 3; document.getElementById('mainImg').src = imgList[Pg]; } function Pick4() { var Pg = 4; document.getElementById('mainImg').src = imgList[Pg]; } function Pick5() { var Pg = 5; document.getElementById('mainImg').src = imgList[Pg]; } function Pick6() { var Pg = 6; document.getElementById('mainImg').src = imgList[Pg]; } var imgList = [ "../Assets/Images_Revised/40_kitchen.jpg", "../Assets/Images_Revised/40_stair.jpg", "../Assets/Images_Revised/C_front2.jpg", "../Assets/Images_Revised/C_rear_side_combo.jpg", "../Assets/Images_Revised/C_side.jpg", "../Assets/Images_Revised/Y_combo.jpg", "../Assets/Images_Revised/Y_window.jpg" ]; onload = function() { // document.getElementById('mainImg').src = imgList[0]; Prev(); } </script> Here is my Menu: Quote: <a href="#" onclick="Prev();return false"><</a><a href="#" onclick="Pick0();return false">1</a> <a href="#" onclick="Pick1();return false">2</a> <a href="#" onclick="Pick2();return false">3</a> <a href="#" onclick="Pick3();return false">4</a> <a href="#" onclick="Pick4();return false">5</a> <a href="#" onclick="Pick5();return false">6</a> <a href="#" onclick="Pick6();return false">7</a> <a href="#" onclick="Next();return false">></a> Hello guys, I spent a lot of time searching for a good image/video gallery, but didn't find, what I'm looking for. All I need is a code, that I can insert to my webpage. I need a thumbnail gallery (images or videos), that I can scroll by next/previous buttons a open it by clicking in new window. This is how LightBox and VideoLightBox work, but they don't have the next/previous buttons. I found js ImageScroller, but it can't work together with VideoLightBox... Is there anybody solving this problem? Well I found this page http://codecanyon.net/item/jquery-ho...preview/112734 but I need it even for videos. If there is a solution for both images and videos... Thanks for help, DveD I'm designing my site at the moment and want to include some photos (500 x 331 pixs). I want to have the images load within the same space without the page reloading like flickr. I think it's done using AJAX Javascript or something similar but have been unable to find any tutorials which deal specifically with this although I'm sure there are many (links would be greatfully received). I want to be able to navigate through them with arrows, or a row of numbers or something simlar and straight forward. simlar to these: http://www.itsnicethat.com/articles/3011-things http://www.timgeorgedesign.co.uk/jump_print.html (this is flash I think) I'm using Dreamweaver, and have been working mainly in the design and split views so don't know too much about coding, but I was hoping to find prehaps a few lines of script that I might be able to paste in and edit to make this, as the rest of the page is all done or a decent pre made gallery plug-in. Thanks for any help. Hello Everyone, Sir i used setTimeout() function in my image gallery to scroll images , i used setTimeout("myfunction()",1) in my script. Now my image gallery is working properly but problem is that the speed of scrolling images if normal in firefox, but in internet explorer it is slow, and in google chrome it is very fast , Sir how to resolve this problem This is my javascript code : Code: <html> <head><title> My Gallery </title> <style type="text/css"> #mainimagecontainer { position:relative; width:600px; height:400px; border-width:1px; border-color:#cccccc #aaaaaa #aaaaaa #cccccc; border-style:solid; padding:5px; } #imagebuttoncont { width:100%; position:relative; border-bottom:1px solid #cccccc; text-align:center; height:40px; } #buttontable .td { padding:3px; position:relative; } #buttontable .td a { text-decoration:none; font-size:14px; color:gray; font-family:verdana; } #imagecontainer { position:relative; width:575px; height:350px; overflow:hidden; background-color:#efefef; border-width:1px; border-color:#cccccc #aaaaaa #aaaaaa #cccccc; border-style:solid; } #imgs { height:350px; position:relative; left:0px; top:0px; } </style> <script type="text/javascript"> var previous1=0; var next1=0; var value=575; var imgcounter=1; var flag=1; function next() { var element = document.getElementById("imgs"); if(next1 >value && flag==1) { value = next1+575; imgcounter=imgcounter+1; if(imgcounter==5) { previous(); } return; } next1 = next1+25; element.style.left = "-"+next1+"px"; setTimeout("next()",1); } function previous() { var element = document.getElementById("imgs"); if(next1 <= 0) { next1=0; value=575; imgcounter=1; return; } next1 = next1-25; element.style.left = "-"+next1+"px"; setTimeout("previous()",1); } </script> </head> <body > <div id="mainimagecontainer" > <div id="imagebuttoncont"> <table id="buttontable" align="center"> <tr> <td class="td"> <div id="link2"> <a href="#" onclick="next()" > next </a> </div></td> </tr> </table> </div> <center> <div id="imagecontainer"> <div id="imgs"> <table id="imagegall" > <tr> <td width="590px" height="350px" > <img src="img1.jpg" height="350px" width="590px" > </td> <td width="590px" height="350px" > <img src="img2.jpg" height="350px" width="590px" > </td> <td width="590px" height="350px" > <img src="img3.jpg" height="350px" width="590px" > </td> <td width="590px" height="350px" > <img src="img4.jpg" height="350px" width="590px" > </td> </tr> </table> <div id="imgs"> </div> </center> </div> </body> </html> Please some one help me , please add four photos to see image gallery Hi everyone, I'm not sure I'm posting this correctly (or if anyone is actually willing to help me out ) but I'm looking for the javascript code to create the following comparative image gallery. http://i528.photobucket.com/albums/d...evised-RBA.jpg Basically the image gallery needs to do the following. When I click on an image (small grey boxes on the bottom), that specific image will appear in the first window. When I click on another image, it will appear in the second window. And finally, click on one more image so that it appears in the third window. If I want to remove one of the images from the large window, I want to do so by clicking the clear button underneath the image I want to remove. If anyone could help me out with this, I would be EXTREMELY grateful! hi i just ripped stepcarousel out of my file (i never could fix the offset parent error so i just took it out) and i was looking at CMotion Image Gallery the problem is i dont need it to go side to side i need it to scroll up and down. i have a javascript element that is display as block, what im trying to do is load some videos in the box with a scroll bar. but i cannot get the scroll bar to show up. i tried overflow:scroll overflow:auto in css. i tried wrapping the videos with a div with overflow style i tried ripping out the content of the vids and putting that in a sep file and then using iframe to load it. I also tried changing the display to table other than block and even set it to none still nothing.. i do know that stepcarousel and CMotion Image Gallery at least function with their div wrap so im not sure why my div wrap is not working. but is there anything like CMotion Gallery or Stepcarousel that will force the div BUT scroll up and down. or better yet whats the best way to force a scroll div in a block.. this does not work.. Code: <div style="overflow:scroll; height:300px;"> my video content </div> i never knew it could be so hard to do the easiest thing, i have made scrollers before not sure why this one is not working. Hello everyone, I am sorry to take up your time, I need help with some small issues, I am not familiar with java / php. I will post my problems on different threads. --- N0 1 is: I need a image gallery like this: Big image is 540px wide and beneath it is a thumbnail that activates the big image on click. I have one now but I am not satisfied with it. The link is: http://sfantipa.ro/gal_iarna.html . What I do not like is the fact that it scales the vertical images as the same weight and distorts them and I want the thumbnails to be on 1 row with before and next < > buttons or scrolled by mouse over at the left and right row, doesnt really matter which one. The thumbnail will have some space between them but they will load them as they are not scale them to predefined w/h. No text description and the thumbnails are always displayed, not hide... I am asking here because although I found many scripts, none is the one I need Can anyone help please? Thanks fokes! |