some thumbnail error handling
authorAndreas Unterkircher <unki@netshadow.at>
Tue, 19 Jun 2007 18:56:05 +0000 (18:56 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Tue, 19 Jun 2007 18:56:05 +0000 (18:56 +0000)
force thumbnail generation if the file is inserted
into the phpfspot database, but the thumbnails are
not existing (anymore?)

git-svn-id: file:///var/lib/svn/phpfspot/trunk@113 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot_img.php

index 2ffec5fa82b5c7f24ddd90c2483981884d5624db..9c426a30ce20f678d9daa95eb2c141305d491faa 100644 (file)
@@ -536,7 +536,7 @@ class PHPFSPOT {
 
    } // check_config_table
 
-   public function gen_thumb($idx = 0, $fromcmd = 0)
+   public function gen_thumb($idx = 0, $fromcmd = 0, $force = 0)
    {
       $details = $this->get_photo_details($idx);
 
@@ -546,7 +546,7 @@ class PHPFSPOT {
       if($fromcmd) print "Image [". $idx ."] ". $details['name'] ." Thumbnails:";
 
       /* if the file hasn't changed there is no need to regen the thumb */
-      if($file_md5 == $this->getMD5($idx)) {
+      if(!$force && $file_md5 == $this->getMD5($idx)) {
          if($fromcmd) print " file has not changed - skipping\n";
          return;
       }
index 60c06b00d47a2be5565c300332e44bca353e14ef..e3b0852108f5bdb49e469b0a68939f3188f9b422 100644 (file)
@@ -32,6 +32,13 @@ class PHPFSPOT_IMG {
          $fullpath = $this->parent->translate_path($details['directory_path'])  ."/thumbs/". $width ."_". $details['name'];
       }
 
+      if(!file_exists($fullpath)) {
+         $this->parent->gen_thumb($idx, 0, 1);
+      }
+      if(!is_readable($fullpath)) {
+         die("File ". $fullpath ." is not readable. Check the permissions");
+      }
+
       $tmp = getimagesize($fullpath);
       $mime = $tmp['mime'];