正在显示
1 个修改的文件
包含
27 行增加
和
7 行删除
| @@ -425,10 +425,20 @@ if (!function_exists('getImageUrl')) { | @@ -425,10 +425,20 @@ if (!function_exists('getImageUrl')) { | ||
| 425 | $url[] = getImageUrl($v); | 425 | $url[] = getImageUrl($v); |
| 426 | } | 426 | } |
| 427 | }else{ | 427 | }else{ |
| 428 | - if($location == 1){ | 428 | + $imageModel = new Image(); |
| 429 | + if (strpos($path, '.') !== false) { | ||
| 430 | + $info = $imageModel->read(['path'=>['like','%'.$path.'%']]); | ||
| 431 | + }else{ | ||
| 432 | + $info = $imageModel->read(['hash'=>$path]); | ||
| 433 | + } | ||
| 434 | + if(!empty($info)){ | ||
| 435 | + if($info['is_cos'] == 1){ | ||
| 429 | $cos = config('filesystems.disks.cos'); | 436 | $cos = config('filesystems.disks.cos'); |
| 430 | $cosCdn = $cos['cdn']; | 437 | $cosCdn = $cos['cdn']; |
| 431 | - $url = $cosCdn.$path; | 438 | + $url = $cosCdn.$info['path']; |
| 439 | + }else{ | ||
| 440 | + $url = url($info['path']); | ||
| 441 | + } | ||
| 432 | }else{ | 442 | }else{ |
| 433 | $url = url($path); | 443 | $url = url($path); |
| 434 | } | 444 | } |
| @@ -444,16 +454,26 @@ if (!function_exists('getFileUrl')) { | @@ -444,16 +454,26 @@ if (!function_exists('getFileUrl')) { | ||
| 444 | * @method :post | 454 | * @method :post |
| 445 | * @time :2023/7/20 16:46 | 455 | * @time :2023/7/20 16:46 |
| 446 | */ | 456 | */ |
| 447 | - function getFileUrl($path,$location = 1){ | ||
| 448 | - if(is_array($path)){ | ||
| 449 | - foreach ($path as $v){ | 457 | + function getFileUrl($hash){ |
| 458 | + if(is_array($hash)){ | ||
| 459 | + foreach ($hash as $v){ | ||
| 450 | $url[] = getFileUrl($v); | 460 | $url[] = getFileUrl($v); |
| 451 | } | 461 | } |
| 452 | }else{ | 462 | }else{ |
| 453 | - if($location == 1){ | 463 | + $fileModel = new File(); |
| 464 | + if (strpos($hash, '.') !== false) { | ||
| 465 | + $info = $fileModel->read(['path'=>['like','%'.$hash.'%']]); | ||
| 466 | + }else{ | ||
| 467 | + $info = $fileModel->read(['hash'=>$hash]); | ||
| 468 | + } | ||
| 469 | + if(!empty($info)){ | ||
| 470 | + if($info['is_cos'] == 1){ | ||
| 454 | $cos = config('filesystems.disks.cos'); | 471 | $cos = config('filesystems.disks.cos'); |
| 455 | $cosCdn = $cos['cdn']; | 472 | $cosCdn = $cos['cdn']; |
| 456 | - $url = $cosCdn.$path['path']; | 473 | + $url = $cosCdn.'/upload'.$info['path']; |
| 474 | + }else{ | ||
| 475 | + $url = url('upload'.$info['path']); | ||
| 476 | + } | ||
| 457 | }else{ | 477 | }else{ |
| 458 | $url = url($path['path']); | 478 | $url = url($path['path']); |
| 459 | } | 479 | } |
-
请 注册 或 登录 后发表评论