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 4 of 4
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question do not show thumbnail if not in range

    hi,

    my code below shows up to 6 thumbnail images I want to only show the thumbnails if there are more than 1 *note this one is not in the range: <img src="'.escape($directory['items']['photo']).'" alt="" />

    Please help

    PHP Code:
    if (!empty($directory['items']['photo'])) {
                                        
    $list = array();
                                                foreach ( 
    range1) as $i ) {
                                                if ( ! 
    $image escape($directory["items"]["photo_$i"]))
                                                continue;
                                                
    $list[] = "<li><img src='$image' alt='' /></li>";
                                                }
                                            echo 
    ' <div id="image" class="photo"></div>';
                                            echo 
    '<ul class="gallery">';
                                            echo 
    '<li class="active"><img src="'.escape($directory['items']['photo']).'" alt="" /></li>';    
                                                
                                                if ( 
    $list )
                                                echo 
    implode"\n"$list );    
                                            echo 
    '</ul>'

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,922
    Thanks
    15
    Thanked 229 Times in 229 Posts
    You just need a conditional statement based on the number of images involved, and the statement chooses between two blocks of code, one for a single image, the other for multiple images.
    PHP Code:
    if (count($list)==1){ do this }
    else{ do 
    this stuff 
    You may need something for no images too.
    Last edited by DrDOS; 08-21-2012 at 03:45 PM. Reason: error in code

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    thanks but that didn't work

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,922
    Thanks
    15
    Thanked 229 Times in 229 Posts
    Quote Originally Posted by jarv View Post
    thanks but that didn't work
    I changed the code, it should work now.


  •  

    Posting Permissions

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