https://www.icyphoenix.com/viewtopic.php?f=35&t=6238&p=42494#p42494 ----------------------------------- Danielc Sat 08 Aug, 2009 20:36 Re: No Thumbnail After Changing Server In External Pictures ----------------------------------- I solved it!!!!!!!!!!!!!!!!!!!!!!!!! I modified image_thumbnail.php file with some changes in my file. This is the solution: ¿What will you need?: - A folder in the root of your web called [b]tmp[/b] (you can change it in the modified file) - A folder in the root of your web called [b]fuentes[/b] (you can change it in the modified file) - True type font segoeuib.ttf, in fuentes folder (you can change it in the modified file) - Icy Phoenix :mrblue: - These instructions: [b]Instructions:[/b] [code linenumbers=false] # #-------------[ Begin ]----------- # # #------------[ OPEN ]-------------- # /image_thumbnail.php # #-------------[ FIND]-------------- # require(ALBUM_MOD_PATH . 'album_image_class.' . PHP_EXT); # #-------------[ AFTER ADD ] ---------- # //Danielc's MOD - Vars Declaration START $tmppath = $_SERVER['DOCUMENT_ROOT'] . '/tmp/'; // You must have this dir in the root. $thumbspath = $_SERVER['DOCUMENT_ROOT'] . '/files/thumbs/'; // The thumbs directory $urltothumbs = 'http://www.danielc.22web.net/files/thumbs/'; // The URL to thumbs directory //Danielc's MOD - Vars Declaration END # #-------------[ FIND]-------------- # if ($image_processed == false) { # #-------------[ AFTER ADD ] ---------- # // Danielc's Mod Start $filename = $pic_thumbnail_prefix . '_' . $pic_filename; $grab = curl_init(); curl_setopt($grab, CURLOPT_URL, $pic_fullpath); curl_setopt($grab, CURLOPT_HEADER, false); curl_setopt($grab, CURLOPT_RETURNTRANSFER, true); $grabbed = curl_exec($grab); curl_close($grab); //ECHO "DEBUG: Nombre de archivo = $filename
"; $file = fopen($tmppath.$filename, 'w'); fwrite($file, $grabbed); fclose($file); $pic_fullpath = $tmppath . $filename; fwrite($log, "pic_fullpath = $pic_fullpath" . PHP_EOL); $pic_local = true; //Danielc's Mod END # #-------------[ FIND]-------------- # if ($pic_width > $pic_height) { $thumbnail_width = $board_config['thumbnail_size']; $thumbnail_height = $board_config['thumbnail_size'] * ($pic_height / $pic_width); } else { $thumbnail_height = $board_config['thumbnail_size']; $thumbnail_width = $board_config['thumbnail_size'] * ($pic_width / $pic_height); } $Image = new ImgObj(); if ($pic_filetype == 'jpg') { $Image->ReadSourceFileJPG($pic_fullpath); } else { $Image->ReadSourceFile($pic_fullpath); } $Image->Resize($thumbnail_width, $thumbnail_height); if( $board_config['show_pic_size_on_thumb'] == 1) { $dimension_string = intval($pic_width) . "x" . intval($pic_height) . "(" . intval(filesize($pic_fullpath)/1024) . "KB)"; $Image->Text($dimension_string); } if ($board_config['thumbnail_cache'] == true) { if ($pic_filetype == 'jpg') { $Image->SendToFileJPG($pic_thumbnail_fullpath, $album_config['thumbnail_quality']); } else { $Image->SendToFile($pic_thumbnail_fullpath, $album_config['thumbnail_quality']); } //$Image->SendToFile($pic_thumbnail_fullpath, $board_config['thumbnail_quality']); //@chmod($pic_thumbnail_fullpath, 0777); } if ($pic_filetype == 'jpg') { $Image->SendToBrowserJPG($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']); } else { $Image->SendToBrowser($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']); } if ($Image == true) { $Image->Destroy(); exit; } else { $Image->Destroy(); header('Content-type: image/jpeg'); header('Content-Disposition: filename=thumb_' . $pic_title_reg . '.' . $pic_filetype); readfile($images['no_thumbnail']); exit; } # #-------------[ REPLACE WITH ]-------------- # //--------------------------------- //Danielc's CURL MOD START //--------------------------------- $maxsize = $req_thumb_size; $showoriginalsize = $board_config['show_pic_size_on_thumb']; $jpgquality = $board_config['thumbnail_quality']; $filename = $pic_thumbnail_prefix . '_' . $pic_filename; /*if(file_exists($thumbspath.$filename)){ unlink($thumbspath.$filename); //ECHO "DEBUG: Existencia de archivo previo. Eliminando.
"; }*/ if(file_exists($tmppath.$filename)){ //ECHO "DEBUG: Archivo Subido correctamente a directorio temporal.
"; switch ($pic_filetype){ case 'jpg': $srcimage = imagecreatefromjpeg($tmppath.$filename); //header("Content-type: image/jpeg"); break; case 'jpeg': $srcimage = imagecreatefromjpeg($tmppath.$filename); //header("Content-type: image/jpeg"); break; case 'gif': $srcimage = imagecreatefromgif($tmppath.$filename); //header("Content-type: image/gif"); break; case 'png': $srcimage = imagecreatefrompng($tmppath.$filename); //header("Content-type: image/png"); break; default: $srcimage = imagecreatefromjpeg($tmppath.$filename); //header("Content-type: image/jpeg"); } $pic_width = imagesx($srcimage); $pic_height = imagesy($srcimage); if($pic_width > $maxsize || $pic_height > $maxsize){ if($pic_width > $pic_height){ $ratio = $maxsize / $pic_width; } else { $ratio = $maxsize / $pic_height; } //next calculate the size of the thumbnail $thumbnail_width = $pic_width * $ratio; $thumbnail_height = $pic_height * $ratio; } else { $thumbnail_width = $pic_width; $thumbnail_height = $pic_height; } //ECHO "DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "
"; if($showoriginalsize == 0){ $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height); //ECHO "DEBUG: Showoriginalsize deshabilitado
"; } else { //ECHO "DEBUG: Showoriginalsize habilitado
"; $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height + 20); $color = ImageColorAllocate($thumbnail, 0, 0, 0); imagefilledrectangle($thumbnail, 0, $thumbnail_height, $thumbnail_width, $thumbnail_height + 20, $color); $color_texto = ImageColorAllocate($thumbnail, 255, 255, 255); $peso = filesize($tmppath.$filename); $texto = $pic_width . "x" . $pic_height . "px " . round(($peso/1024)) . " KB"; //ECHO "DEBUG: texto = $texto
"; $fuente = $_SERVER['DOCUMENT_ROOT'] . '/fuentes/segoeuib.ttf'; $bounds[] = array(); $bounds = imageftbbox(10,0,$fuente, $texto); $x = $bounds[0] + ($thumbnail_width / 2) - ($bounds[4] / 2); $y = $bounds[1] + (20 / 2) - ($bounds[5] / 2) + $thumbnail_height; //ECHO "DEBUG: x = $x y = $y
"; imagettftext($thumbnail, 10, 0, $x, $y, $color_texto, $fuente, $texto); } imagecopyresampled($thumbnail, $srcimage, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); switch ($pic_filetype) { case "jpg": case "jpeg": header('Content-type: image/jpeg'); imagejpeg($thumbnail); imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality); break; case "gif": header('Content-type: image/gif'); imagegif($thumbnail); imagegif($thumbnail, $thumbspath.$filename); break; case "png": header('Content-type: image/png'); imagepng($thumbnail); imagepng($thumbnail, $thumbspath.$filename); break; default: header('Content-type: image/jpeg'); imagejpeg($thumbnail); imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality); } @chmod($thumbspath.$filename, 0777); imagedestroy($thumbnail); unlink($tmppath.$filename); } //--------------------------------- //Danielc's CURL MOD END //--------------------------------- # #----------------[ SAVE ] ---------- # [/code]