Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/10/2008, 23:07
kenso
 
Fecha de Ingreso: enero-2008
Mensajes: 214
Antigüedad: 18 años, 9 meses
Puntos: 3
ayuda con codigo?? para hacer thumbnails

bueno este es el codigo que tengo para hacer thumbnails, y si sirve y todo, osea si me los hace resize y todo, el uniko inconveniente es que cuando kiero abrir una imagen si la habre pero ya en otra pagina, y pos kiero que me habra la imagen en la misma asi como en hi5 que tiene sus imagenes y que si le das click en una te la habre pero en la misma pagina. alguien sabe como hacerlo?? desde ya gracias


Código PHP:
<?php
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) 
{
  
$pathToImages = "img/";
  
$dir = opendir( $pathToImages );

  while (
false !== ($fname = readdir( $dir ))) {
    
$info = pathinfo($pathToImages . $fname);
    if ( 
strtolower($info['extension']) == 'jpg' ) 
    {
      echo 
"Creating thumbnail for {$fname} <br />";

      
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
      
$width = imagesx( $img );
      
$height = imagesy( $img );

      
$new_width = $thumbWidth;
      
$new_height = floor( $height * ( $thumbWidth / $width ) );

      
$tmp_img = imagecreatetruecolor( $new_width, $new_height );

      
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );

      
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
    }
  }
  
closedir( $dir );
}

function 
createGallery( $pathToImages, $pathToThumbs ) 
{
  echo 
"Creating gallery.html <br />";

  echo  
"<html>";
  echo  
"<head><title>Thumbnails</title></head>";
  echo  
"<body>";
  echo  
"<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">";
  echo  
"<tr>";

  
$dir = opendir( $pathToThumbs );

  
$counter = 0;
  while (
false !== ($fname = readdir($dir)))
  {
    if (
$fname != '.' && $fname != '..') 
    {
      echo  
"<td valign=\"middle\" align=\"center\"><a href=\"{$pathToImages}{$fname}\">";
      echo  
"<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
      echo  
"</a></td>";

      
$counter += 1;
      if ( 
$counter % 4 == 0 ) { $output .= "</tr><tr>"; }
    }
  }
  
closedir( $dir );

  echo  
"</tr>";
  echo  
"</table>";
  echo  
"</body>";
  echo  
"</html>";

}

createThumbs("img/","thumbs/",100);
createGallery("img/","thumbs/");
?>