"; } else { // 默认显示 100x100 的图片 $thumbnailImages = array_map(function ($imageUrl) use ($boxSize) { $imageUrl= CommonHelper::ossUrl($imageUrl); $extension = pathinfo($imageUrl, PATHINFO_EXTENSION); if ($extension == 'svg') { return $imageUrl; } else { return $imageUrl . "?x-oss-process=image/resize,m_pad,h_{$boxSize},w_{$boxSize},color_ffffff"; } }, $images); // 生成点击查看大图的链接 $largeImages = array_map(function ($imageUrl) use ($imgSize) { $imageUrl= CommonHelper::ossUrl($imageUrl); $extension = pathinfo($imageUrl, PATHINFO_EXTENSION); if ($extension == 'svg') { return $imageUrl; } else { return $imageUrl . "?x-oss-process=image/resize,m_lfit,w_{$imgSize},h_{$imgSize}"; } }, $images); // 显示缩略图,并添加点击查看大图的功能 $html = ''; foreach ($thumbnailImages as $index => $thumbnailUrl) { $largeUrl = $largeImages[$index]; $html .= ""; } return $html; // // //默认用等比例缩放 // $process = "?x-oss-process=image/resize,h_{$imgSize},m_lfit"; // $html = '
'; // foreach ($images as $image) { // $html .= "
// //
"; // } // $html .= '
'; } return $html; } /* * 返回oss的url */ public static function ossUrl($imageUrl) { if (strpos($imageUrl, 'http:') === 0 || strpos($imageUrl, 'https:') === 0) { return $imageUrl; } if (env('OSS_DOMAIN')) { return "http://".env('OSS_DOMAIN').'/'.$imageUrl; } return "http://".env('OSS_BUCKET').'.'.env('OSS_ENDPOINT').'/'.$imageUrl; } /* * 替换新增与编辑的url,在后边加上指定的参数 (适用于弹出框的新增与编辑) * $addButton = '.tree-quick-create'; * $editButton = '.tree-quick-edit'; * $paramsUrl = 'location=0'; */ public static function replaceAddEditerUrl($addButton,$editButton,$paramsUrl) { Admin::script( <<