DataObjects/Images.php
authorAlan <alan@roojs.com>
Mon, 10 Jan 2022 05:28:19 +0000 (13:28 +0800)
committerAlan <alan@roojs.com>
Mon, 10 Jan 2022 05:28:19 +0000 (13:28 +0800)
DataObjects/Images.php

index 10089ae..1c2b325 100644 (file)
@@ -841,13 +841,20 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
     function createFromData($data)
     {   
         
+        if (0 === strpos("data:", $data)) {
+            // data:image/png;base64, 
+            $data = substr($data,5);
+            $bits = explode(";", $data);
+            $this->mimetype = $bits[0];
+        }
+        
         $this->mimetype= strtolower($this->mimetype);
         
         $explode_mimetype = explode('/', $this->mimetype);
         
         if (array_shift($explode_mimetype) == 'image') { 
         
-            $imgs = @getimagesize($data);
+            $imgs = @getimagesize('data://'. $data);
             
             if (!empty($imgs) && !empty($imgs[0]) && !empty($imgs[1])) {
                 list($this->width , $this->height)  = $imgs;