Jump to content

joeysnacks

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by joeysnacks

  1. Hi I am trying display thumbs from a directory, BUT , I cannot figure out how to show more then just .jpg. For example, how could I make this code show the following file extensions, .jpg .png .gif ? Here is the code spinet and if you could advise that would be awesome Thanks so much for your time in advance <?php $largeArray = glob("images/*.jpg"); $counter = 0; foreach (array_slice(glob("images/thumbs/*.jpg"),0,600) as $thumb) { echo ("<div class='thumbgall'><a href='$largeArray[$counter]' rel='lightbox'><img src='$thumb'/></a></div>"); $counter++; } ?>
  2. Thanks so much, for the fast response I will take your suggestion and look for some code with the glob() instead I am just trying to basically display and resize pictures from a folder using the GD. nothing crazy Just kinda new to this
  3. Hi Everyone, I am a noob so forgive me I tried looking this up myself But I am still confused. Basically, I am trying to use the above code to display a gallery of images from my images folder on my image site. But this free code I found below Pulls the images from the /root not a named directory where the images are stored. Would someone be kind enough to tell me how I can get the script below to pull the large images from a folder called "images" Vs the script looking for the images the root. Thanks so much in advance <?php # SETTINGS $max_width = 100; $max_height = 100; function getPictureType($ext) { if ( preg_match('/jpg|jpeg/i', $ext) ) { return 'jpg'; } else if ( preg_match('/png/i', $ext) ) { return 'png'; } else if ( preg_match('/gif/i', $ext) ) { return 'gif'; } else { return ''; } } 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>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UFT-8" /> <title>Pictures</title> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <style type="text/css"> #pictures li { float:left; height:<?php echo ($max_height + 10); ?>px; list-style:none outside; width:<?php echo ($max_width + 10); ?>px; text-align:center; } img { border:0; outline:none; } </style> </head> <body> <?php getPictures(); ?> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> </body> </html>
  4. Hi Everyone, I am still learning php and I found this forum on Google , when searching for an answer and it seemed like a great place so I joined Nice to meet you all Joseph
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.