DataObjects/Core_enum.php
[Pman.Core] / DataObjects / Images.php
index 47d3ad6..ad8769b 100644 (file)
@@ -768,15 +768,21 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
     
     function toBase64()
     {
+        if(!preg_match('/^image\//', $this->mimetype)){
+            return false;
+        }
+        
         $file = $this->getStoreName();
         
         if(!file_exists($file)){
-            return '';
+            return false;
         }
         
-        $type = pathinfo($path, PATHINFO_EXTENSION);
-        $data = file_get_contents($path);
-        $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
+        $data = file_get_contents($file);
+        
+        $base64 = 'data:' . $this->mimetype . ';base64,' . base64_encode($data);
+        
+        return $base64;
     }
     
  }