作者 lyh

hx

@@ -32,9 +32,15 @@ class TestController extends BaseController @@ -32,9 +32,15 @@ class TestController extends BaseController
32 <p>&nbsp;</p> 32 <p>&nbsp;</p>
33 <p><a href="tel:+86%2018825057975">Tel:+86 18825057975</a></p> 33 <p><a href="tel:+86%2018825057975">Tel:+86 18825057975</a></p>
34 <p><a href="mailto:edinguas@gmail.com">Email:edinguas@gmail.com</a></p>'; 34 <p><a href="mailto:edinguas@gmail.com">Email:edinguas@gmail.com</a></p>';
35 - $newsLogic = new NewsLogic();  
36 - $key = $newsLogic->processImage($test);  
37 - $this->response('success',Code::SUCCESS,['key'=>$key]);  
38 - } 35 + $pattern = '/<img\s+[^>]*src=["\']([^"\']+)["\']/i';
  36 + $matches = [];
  37 + // Use preg_match_all to find all src attributes
  38 + preg_match_all($pattern, $inputString, $matches);
39 39
  40 + // Return an array of all src URLs found
  41 + return $matches[1];
  42 +// $newsLogic = new NewsLogic();
  43 +// $key = $newsLogic->processImage($test);
  44 + $this->response('success',Code::SUCCESS,$matches[1]);
  45 + }
40 } 46 }
@@ -231,6 +231,7 @@ class NewsLogic extends BaseLogic @@ -231,6 +231,7 @@ class NewsLogic extends BaseLogic
231 $base64Data = $matches[2][$index]; // Base64数据 231 $base64Data = $matches[2][$index]; // Base64数据
232 // 解码Base64图片 232 // 解码Base64图片
233 $decodedData = base64_decode($base64Data); 233 $decodedData = base64_decode($base64Data);
  234 + return $decodedData;
234 if ($decodedData === false) { 235 if ($decodedData === false) {
235 continue; // 如果解码失败,则跳过 236 continue; // 如果解码失败,则跳过
236 } 237 }