lvhao 1 month ago
parent
commit
193ca301cb
1 changed files with 11 additions and 6 deletions
  1. 11 6
      core/CoreApp/controllers/Color.php

+ 11 - 6
core/CoreApp/controllers/Color.php

@@ -621,12 +621,17 @@ class Color extends Start_Controller {
 						}
 						else if($v != '')
 						{
-							$imagePath = str_replace('http://'.$_SERVER['HTTP_HOST'],'/www/wwwroot/1.wepolicy.cn',$v);
-							var_dump($imagePath);
-							die;
-							$imageData = file_get_contents($imagePath);
-							$base64 = 'data:' . mime_content_type($imagePath) . ';base,' . base64_encode($imageData);							
-							$info_list[$key]['img'] = "<img width='70' src='".$base64."' data-src='".$v."'>";
+							$imageData = file_get_contents($v);
+							$finfo = new finfo(FILEINFO_MIME_TYPE);
+							$mimeType = $finfo->buffer($imageData);
+
+							// 转换为 Base64
+							$base64 = base64_encode($imageData);
+
+							// 构建 Data URI
+							$dataUri = 'data:' . $mimeType . ';base64,' . $base64;
+						
+							$info_list[$key]['img'] = "<img width='70' src='".$$dataUri."'>";
 						}else{
 							$info_list[$key]['img'] = '';
 						}