Ver Mensaje Individual
  #9 (permalink)  
Antiguo 11/02/2010, 09:11
Masane
 
Fecha de Ingreso: marzo-2008
Mensajes: 207
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Guardar thumbnails

Y el resto del código:

Código PHP:
Ver original
  1. <?php
  2.  
  3. /**
  4.  *
  5.  */
  6. function get_document_root ($src) {
  7.  
  8.     // check for unix servers
  9.     if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $src)) {
  10.         return $_SERVER['DOCUMENT_ROOT'];
  11.     }
  12.  
  13.     // check from script filename (to get all directories to timthumb location)
  14.     $parts = array_diff(explode('/', $_SERVER['SCRIPT_FILENAME']), explode('/', $_SERVER['DOCUMENT_ROOT']));
  15.     $path = $_SERVER['DOCUMENT_ROOT'];
  16.     foreach ($parts as $part) {
  17.         $path .= '/' . $part;
  18.         if (file_exists($path . '/' . $src)) {
  19.             return $path;
  20.         }
  21.     }    
  22.    
  23.     // the relative paths below are useful if timthumb is moved outside of document root
  24.     // specifically if installed in wordpress themes like mimbo pro:
  25.     // /wp-content/themes/mimbopro/scripts/timthumb.php
  26.     $paths = array(
  27.         ".",
  28.         "..",
  29.         "../..",
  30.         "../../..",
  31.         "../../../..",
  32.         "../../../../.."
  33.     );
  34.    
  35.     foreach ($paths as $path) {
  36.         if(file_exists($path . '/' . $src)) {
  37.             return $path;
  38.         }
  39.     }
  40.    
  41.     // special check for microsoft servers
  42.     if (!isset($_SERVER['DOCUMENT_ROOT'])) {
  43.         $path = str_replace("/", "\\", $_SERVER['ORIG_PATH_INFO']);
  44.         $path = str_replace($path, "", $_SERVER['SCRIPT_FILENAME']);
  45.        
  46.         if (file_exists($path . '/' . $src)) {
  47.             return $path;
  48.         }
  49.     }    
  50.    
  51.     displayError('file not found ' . $src);
  52.  
  53. }
  54.  
  55.  
  56. /**
  57.  * generic error message
  58.  */
  59. function displayError($errorString = '') {
  60.  
  61.     header('HTTP/1.1 400 Bad Request');
  62.     die($errorString);
  63.    
  64. }
  65. ?>

Lo ideal sería del tirón crear el thumbnail a partir de la imagen externa (sin tener que copiarla a mi servidor, como estoy haciendo ahora mismo, y guardar el thumbnail en una carpeta con un nombre dado y poder llamarlo luego desde la home estática, pero con tantas funciones me hago un lío.

¿Alguien que sepa ayudarme?

Muchas gracias a todos y perdón por pegaros tanto código :( .