Explorar o código

images的处理

lizhen hai 5 días
pai
achega
ab73ade7d6
Modificáronse 1 ficheiros con 16 adicións e 6 borrados
  1. 16 6
      application/common.php

+ 16 - 6
application/common.php

@@ -532,8 +532,12 @@ if (!function_exists('info_domain_image')) {
         }
         foreach ($data as $key => $val) {
             if (in_array($key, $field)) {
+                $datatype = 'string';
+                if(in_array($key, ['images'])) {
+                    $datatype = 'array';
+                }
 
-                $data[$key] = one_domain_image($val);
+                $data[$key] = one_domain_image($val,$datatype);
             }
         }
         return $data;
@@ -542,10 +546,10 @@ if (!function_exists('info_domain_image')) {
 if (!function_exists('one_domain_image')) {
 //支持单个字段,需要增加domain_cdnurl
 //支持image,images
-    function one_domain_image($one)
+    function one_domain_image($one,$datatype = 'string')
     {
         if (!$one) {
-            return $one;
+            return $datatype == 'string' ? $one : [];
         }
         if (strpos($one, ',')){
             //逗号隔开的多个图片
@@ -553,11 +557,17 @@ if (!function_exists('one_domain_image')) {
             foreach ($one as $k => $v) {
                 $one[$k] = localpath_to_netpath($v);
             }
-            $one = implode(',',$one);
+            //$one = implode(',',$one);
+            return $one;
         } else {
-            $one = localpath_to_netpath($one);
+            if($datatype == 'array'){
+                $rs[] = localpath_to_netpath($one);
+            }else{
+                $rs = localpath_to_netpath($one);
+            }
+            return $rs;
         }
-        return $one;
+
     }
 }
 if (!function_exists('localpath_to_netpath')) {