DataObjects/Images.php
authorEdward <edward@roojs.com>
Wed, 7 May 2014 07:59:52 +0000 (15:59 +0800)
committerEdward <edward@roojs.com>
Wed, 7 May 2014 07:59:52 +0000 (15:59 +0800)
DataObjects/Images.php

index 0faa750..8a495c9 100644 (file)
@@ -107,7 +107,22 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
                file_put_contents($path, $q['_source']); 
             }
             
+             $imageInfo = getimagesize($path);
             
+            require_once 'File/MimeType.php';
+            $y = new File_MimeType();
+            $ext = $y->toExt(trim((string) $imageInfo['mime'] ));
+            
+            if (!preg_match("/\." . $ext."$/", $path, $matches)) {
+                rename($path,$path.".".$ext);
+                $path.= ".".$ext;
+            }
+            
+            if (!$this->createFrom($path)) {
+                $roo->jerr("error on auto save making image");
+            }
+            
+            $roo->addEvent("AUTOSAVE", $this, $this->toEventString());
         }
         
     }