dever 3 роки тому
батько
коміт
d65ad35a13
1 змінених файлів з 38 додано та 7 видалено
  1. 38 7
      lib/Store/Qiniu.php

+ 38 - 7
lib/Store/Qiniu.php

@@ -194,15 +194,28 @@ class Qiniu extends Core implements Config
             if (!strstr($source, 'http')) {
                 $source = $this->data['host'] . $source;
             }
+            /*
             if (strstr($source, '?')) {
                 $prefix = '&';
             } else {
                 $prefix = '?';
+            }*/
+            $prefix = '';
+            if (!strstr($source, 'imageMogr2')) {
+                $prefix = '?imageMogr2';
             }
-            $dest = $source . $prefix . 'imageView2/2/w/'.$config['width'].'/h/'.$config['height'];
+            if (strstr($source, '|imageslim')) {
+                $source = str_replace('|imageslim', '', $source);
+            }
+            //$dest = $source . $prefix . 'imageView2/2/w/'.$config['width'].'/h/'.$config['height'];
+            if ($config['height'] <= 0) {
+                $config['height'] = '';
+            }
+            $dest = $source . $prefix . '/thumbnail/'.$config['width'].'x'.$config['height'];
 
             if (isset($config['compress']) && $config['compress'] > 0) {
-                $dest .= '/q/' . $config['compress'];
+                //$dest .= '/q/' . $config['compress'];
+                $dest .= '/quality/' . $config['compress'];
             }
 
             $dest .= '|imageslim';
@@ -232,17 +245,35 @@ class Qiniu extends Core implements Config
             $file = ltrim($temp['path'], '/');
             $file = Dever::db('upload/file')->one(array('file' => $file));
 
+            if (strstr($source, '|imageslim')) {
+                $source = str_replace('|imageslim', '', $source);
+            }
+
             $x = $y = 0;
             if ($file) {
+                if (strstr($source, 'thumbnail/')) {
+                    $temp = explode('thumbnail/', $source);
+                    if (isset($temp[1])) {
+                        $temp = explode('x', $temp[1]);
+                        $width = $file['width'];
+                        $file['width'] = $temp[0];
+                        $radio = $file['width']/$width;
+                        if (isset($temp[1]) && $temp[1]) {
+                            $file['height'] = $temp[1];
+                        } else {
+                            $file['height'] = round($radio*$file['height'], 2);
+                        }
+                    }
+                }
                 list($x, $y) = $this->img()->get_position($file['width'], $file['height'], $config['width'], $config['height'], 'crop', $config['type']);
             }
             
-            if (strstr($source, '?')) {
-                $prefix = '&';
-            } else {
-                $prefix = '?';
+            $prefix = '';
+            if (!strstr($source, 'imageMogr2')) {
+                $prefix = '?imageMogr2';
             }
-            $dest = $source . $prefix . 'imageMogr2/crop/!'.$config['width'].'x'.$config['height'].'a'.$x.'a' . $y;
+
+            $dest = $source . $prefix . '/crop/!'.$config['width'].'x'.$config['height'].'a'.$x.'a' . $y;
 
             $dest .= '|imageslim';
         }