正在显示
1 个修改的文件
包含
18 行增加
和
17 行删除
| @@ -120,12 +120,15 @@ class AiVideoAutoPublish extends Command | @@ -120,12 +120,15 @@ class AiVideoAutoPublish extends Command | ||
| 120 | if(empty($data['remark'])){ | 120 | if(empty($data['remark'])){ |
| 121 | $data['remark'] = $data['title']; | 121 | $data['remark'] = $data['title']; |
| 122 | } | 122 | } |
| 123 | - $data['images'] = array_map(function ($item) { | ||
| 124 | - return [ | ||
| 125 | - 'alt' => $item['title'], | ||
| 126 | - 'url' => $item['url'] ?? '', | ||
| 127 | - ]; | ||
| 128 | - }, $info['gallery']); | 123 | + $data['images'] = array_filter(array_map(function ($item) use ($data) { |
| 124 | + if (!empty($item['url'])) { | ||
| 125 | + return [ | ||
| 126 | + 'alt' => $item['title'] ?? $data['title'], | ||
| 127 | + 'url' => $item['url'], | ||
| 128 | + ]; | ||
| 129 | + } | ||
| 130 | + return null; // 返回 null 让 array_filter 去除 | ||
| 131 | + }, $info['gallery'])); | ||
| 129 | return $data; | 132 | return $data; |
| 130 | }else{ | 133 | }else{ |
| 131 | //聚合页获取当前关联产品的图片 | 134 | //聚合页获取当前关联产品的图片 |
| @@ -144,18 +147,16 @@ class AiVideoAutoPublish extends Command | @@ -144,18 +147,16 @@ class AiVideoAutoPublish extends Command | ||
| 144 | $productModel = new Product(); | 147 | $productModel = new Product(); |
| 145 | $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],'id',['gallery'],'desc',10); | 148 | $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],'id',['gallery'],'desc',10); |
| 146 | foreach ($productList as $info){ | 149 | foreach ($productList as $info){ |
| 147 | - $data['images'] = array_map(function ($item) { | ||
| 148 | - return [ | ||
| 149 | - 'alt' => $item['title'], | ||
| 150 | - 'url' => $item['url'] ?? '', | ||
| 151 | - ]; | ||
| 152 | - }, $info['gallery']); | ||
| 153 | - $data['images'] = array_merge($data['images'],array_map(function ($item) { | ||
| 154 | - return [ | ||
| 155 | - 'alt' => $item['title'], | ||
| 156 | - 'url' => $item['url'] ?? '', | ||
| 157 | - ]; | 150 | + $images = array_filter(array_map(function ($item) use ($data) { |
| 151 | + if (!empty($item['url'])) { | ||
| 152 | + return [ | ||
| 153 | + 'alt' => $item['title'] ?? $data['title'], | ||
| 154 | + 'url' => $item['url'], | ||
| 155 | + ]; | ||
| 156 | + } | ||
| 157 | + return null; // 返回 null 让 array_filter 去除 | ||
| 158 | }, $info['gallery'])); | 158 | }, $info['gallery'])); |
| 159 | + $data['images'] = array_merge($data['images'],$images); | ||
| 159 | } | 160 | } |
| 160 | return $data; | 161 | return $data; |
| 161 | } | 162 | } |
-
请 注册 或 登录 后发表评论