Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display first image

    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:
    PHP Code:
    echo
    "<a href='#' rel='$base/$get_album/$file' class='image'><img src='$base/$thumbs/$file'  border='0' class ='thumb'></a>"
    Here is the jquery:
    Code:
    $(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
    Last edited by steveb533; 12-30-2010 at 08:04 PM.

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    try using live, out side of your document load if you have one

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

    Code:
    <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>
    Last edited by seco; 01-12-2011 at 05:28 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •