tm2000 Posted August 7, 2009 Share Posted August 7, 2009 Hi, I have a great php gallery that I found courtesy of http://www.jkemppainen.com, but what I need to be abel to do is add the file name underneath each thumbnail. I'm a newbie to php, and cannot work out how to do this. This is my demo site: http://www.tygamarketing.com/smartgallery/index.php Any help will be much appreciated!! Thanks in advance! Andy Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/ Share on other sites More sharing options...
JonnoTheDev Posted August 7, 2009 Share Posted August 7, 2009 The filename is obviously used in the <img src= attribute. Find this and echo it under your picture. I dont know your script but as an example: // loop through database table of image files while($row = $db->nrecord()) { print "<img src='images/".$row->filename."' />"; // print the filename under image print "<br />".$row->filename; } Don't take this code and look for it in your script as it will be different. Just find the part that prints out the images. Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-893025 Share on other sites More sharing options...
tm2000 Posted August 7, 2009 Author Share Posted August 7, 2009 Thanks! I think I've found where it prints the thumbnail 0- this is the line I think that does it: echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n"); So do I just add what you sent underneath? Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-893077 Share on other sites More sharing options...
tm2000 Posted August 7, 2009 Author Share Posted August 7, 2009 I can't get it to work! This is the script that I think needs changing: it's php4 if that helps!! See below: <?php function php_thumbnails($imagefolder,$thumbfolder,$lightbox) { //Get image and thumbnail folder from function $images = "portfolio/" . $imagefolder; //The folder that contains your images. This folder must contain ONLY ".jpg files"! $thumbnails = "portfolio/" . $thumbfolder; // the folder that contains all created thumbnails. //Load Images //load images into an array and sort them alphabeticall: $files = array(); if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { //Only do JPG's if(eregi("((.jpeg|.jpg)$)", $file)) { $files[] = array("name" => $file); } } closedir($handle); } //Obtain a list of columns foreach ($files as $key => $row) { $name[$key] = $row['name']; } //Put images in order: array_multisort($name, SORT_ASC, $files); //set the GET variable name $pic = $imagefolder; //Thumbnails //Recursively go trough the array of images and add thmubnails to the page: foreach ($files as $file) { $addy = $_GET[$pic]; $string = $file['name']; // Print the currently viewed thumbnail if( $addy == $file['name'] AND $lightbox == "lb-off") { $name = $file['name']; $splitname = explode (".", $name); $pictitle = str_replace("_"," ",$splitname[0]); echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n"); } // Print thumbnails with link else { // Check if thumbnail already created $name = $file['name']; $splitname = explode (".", $name); $pictitle = str_replace("_"," ",$splitname[0]); if( $lightbox == "lb-on") { $link = "<a rel=\"lightbox[" . $images . "]\" title=\"$splitname[0]\" href=\"" . $images . "/" . $name . "\">"; } else { $link = "<a href=\"?" . $pic . "=" . $file['name'] . "\">"; } if (file_exists("$thumbnails/$splitname[0]_thumb.jpg")) { // Load the thumbnail image echo($link); echo("<img class=\"thumb\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"></a> \n"); } else { // Create a thumbnail image echo($link); echo("<img class=\"thumb\" src=\"thumbnail.php?imagefolder=" . $images . "&thumbfolder=" . $thumbnails . "&name=" . $file['name'] . "&im=" . $images . "/" . $file['name'] . "\" alt=\"$pictitle\"></a> \n"); } } } reset($files); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-893085 Share on other sites More sharing options...
JonnoTheDev Posted August 8, 2009 Share Posted August 8, 2009 echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n<br />\n".$splitname[0]_thumb.jpg); Add to all lines where an image is printed Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-893596 Share on other sites More sharing options...
tm2000 Posted August 10, 2009 Author Share Posted August 10, 2009 Thanks again Neil - but I'm still having trouble! I added your line: echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n<br />\n".$splitname[0]_thumb.jpg); but it didn't work at all (just showed blank screen) - then, I amended your line, as I think maybe the quote marks were in the wrong place at the end? - so now i have: echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n<br />\n.$splitname[0]_thumb.jpg"); but it's still not adding the filename below the thumbnail: http://www.tygamarketing.com/smartgallery/index.php Any ideas? Sorry to be a pain!! (I'm in the very early stages of learning php, so bear with me!) Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-894635 Share on other sites More sharing options...
JonnoTheDev Posted August 10, 2009 Share Posted August 10, 2009 If you get a blank screen you need to turn error reporting on. Add this at the top of your script. ini_set('display_errors', 'on'); Looks like you have a few lines of image echos. Add the extra part to all of them or simply just add a random bit of text after the <img src tag to see if it prints out. Also other bit of code should be <?php echo("<img class=\"thumb_active\" src=\"" . $thumbnails . "/$splitname[0]_thumb.jpg\" alt=\"$pictitle\"> \n<br />\n".$splitname[0]."_thumb.jpg"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-894654 Share on other sites More sharing options...
infiniteacuity Posted August 12, 2009 Share Posted August 12, 2009 try this: echo("<img class=\"thumb\" src=\"thumbnail.php?imagefolder=" . $images . "&thumbfolder=" . $thumbnails . "&name=" . $file['name'] . "&im=" . $images . "/" . $file['name'] . "\" alt=\"$pictitle\"></a> \n"); echo("<br>" . $pictitle . "\n"); Quote Link to comment https://forums.phpfreaks.com/topic/169233-php-image-gallery-help/#findComment-896631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.