quelle Posted December 19, 2010 Share Posted December 19, 2010 Lets say ive got a function like this one function getPictures() { global $max_width, $max_height; if ( $handle = opendir(".") ) { $lightbox = rand(); echo '<ul id="pictures">'; while ( ($file = readdir($handle)) !== false ) { if ( !is_dir($file) ) { $split = explode('.', $file); $ext = $split[count($split) - 1]; if ( ($type = getPictureType($ext)) == '' ) { continue; } if ( ! is_dir('thumbs') ) { mkdir('thumbs'); } if ( ! file_exists('thumbs/'.$file) ) { if ( $type == 'jpg' ) { $src = imagecreatefromjpeg($file); } else if ( $type == 'png' ) { $src = imagecreatefrompng($file); } else if ( $type == 'gif' ) { $src = imagecreatefromgif($file); } if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) { $newW = $oldW * ($max_width / $oldH); $newH = $max_height; } else { $newW = $max_width; $newH = $oldH * ($max_height / $oldW); } $new = imagecreatetruecolor($newW, $newH); imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH); if ( $type == 'jpg' ) { imagejpeg($new, 'thumbs/'.$file); } else if ( $type == 'png' ) { imagepng($new, 'thumbs/'.$file); } else if ( $type == 'gif' ) { imagegif($new, 'thumbs/'.$file); } imagedestroy($new); imagedestroy($src); } echo '<li><a href="'.$file.'" rel="lightbox['.$lightbox.']">'; echo '<img src="thumbs/'.$file.'" alt="" />'; echo '</a></li>'; } } echo '</ul>'; } } What it does is: It checks for files(images) in a directory, check for file types jpg, png or gif cuz I work on gd library and it supports only these 3 type of images and make thumbnails. My problem is I cant change the directory of images, after I do that I just got error or it doesnt read images at all. I tried $dir = "/galerija/"; if ( $handle = opendir($dir) ) But nothing happens, it just leaves me blank space(as I said above it doesnt read images at all) Link to comment https://forums.phpfreaks.com/topic/222102-image-gallery-help-needed/ Share on other sites More sharing options...
PaulRyan Posted December 19, 2010 Share Posted December 19, 2010 I sure this is just a simple change needed. $dir = "/galerija/"; too...... $dir = "galerija/"; Also check to make sure the path is correct, tell me how it goes buddy Regards, Paul. Link to comment https://forums.phpfreaks.com/topic/222102-image-gallery-help-needed/#findComment-1149109 Share on other sites More sharing options...
quelle Posted December 19, 2010 Author Share Posted December 19, 2010 nah not workin' tried both before u said, also tried $dir = "galerija"; always same, nothing happens the div is blank(the space that should be filled with images) EDIT: Sorry for a late reply, was afk never tought someone will reply in minutes Link to comment https://forums.phpfreaks.com/topic/222102-image-gallery-help-needed/#findComment-1149116 Share on other sites More sharing options...
quelle Posted December 19, 2010 Author Share Posted December 19, 2010 omg anyone ? Link to comment https://forums.phpfreaks.com/topic/222102-image-gallery-help-needed/#findComment-1149286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.