...

View Full Version : Display first image



steveb533
12-30-2010, 09:01 PM
Hi
I am trying to make a thumbnail image gallery using PHP to pull in the pictures from an album. I'm using jquery to display the main image when the thumb is clicked. I would like to display the first main image, from the selected album, as the default when the page is opened. Seems like it should be doable but I can't figure it out. here is the php:

echo
"<a href='#' rel='$base/$get_album/$file' class='image'><img src='$base/$thumbs/$file' border='0' class ='thumb'></a>";


Here is the jquery:


$(function() {
$(".image").click(function() {
var image = $(this).attr("rel");
var title = $(this).attr("alt");
var description = $(this).attr("content");
$('#gallery').hide();
$('#gallery').fadeIn('slow');
$('#image').html('<img src="' + image + '"/>');


return false;
});
});


can I just add something before the function? Thanks in advance.

Steve

seco
01-12-2011, 06:20 PM
try using live, out side of your document load if you have one

here is a online example http://www.blueicestudios.com/test/



<script type="text/javascript">

$(".image").live('click', function() {
var image = $(this).attr("rel");
var title = $(this).attr("alt");
var description = $(this).attr("content");
$('#gallery').hide();
$('#gallery').fadeIn('slow');
$('#image').html('<img src="' + image + '"/>');


return false;
});


</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum