|
@@ -10,17 +10,22 @@ class CommonHelper
|
|
|
* $images 格式:['image.jpg','image2.jpg']
|
|
|
* 返回显示的HTML显示图片
|
|
|
*/
|
|
|
- public static function displayImage($images,$size=150)
|
|
|
+ public static function displayImage($images,$boxSize=100,$imgSize=300)
|
|
|
{
|
|
|
- //默认用等比例缩放
|
|
|
- $process = "?x-oss-process=image/resize,h_{$size},m_lfit";
|
|
|
- $html = '<div style="display: flex; flex-wrap: wrap; gap: 5px;">';
|
|
|
- foreach ($images as $image) {
|
|
|
- $html .= "<div style='flex: 1 0 {$size}px; max-width: {$size}px; max-height: {$size}px; padding: 5px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); display: flex; align-items: center; justify-content: center;'>
|
|
|
+ if (empty($images) || $images[0] == null) {
|
|
|
+ $html = "";
|
|
|
+ } else {
|
|
|
+ //默认用等比例缩放
|
|
|
+ $process = "?x-oss-process=image/resize,h_{$imgSize},m_lfit";
|
|
|
+ $html = '<div style="display: flex; flex-wrap: wrap; gap: 5px;">';
|
|
|
+ foreach ($images as $image) {
|
|
|
+ $html .= "<div style='flex: 1 0 {$boxSize}px; width: {$boxSize}px; height: {$boxSize}px; padding: 5px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); display: flex; align-items: center; justify-content: center;'>
|
|
|
<img data-action='preview-img' src='" . self::ossUrl($image).$process . "' style='max-width: 100%; max-height: 100%; object-fit: contain;'>
|
|
|
</div>";
|
|
|
+ }
|
|
|
+ $html .= '</div>';
|
|
|
}
|
|
|
- $html .= '</div>';
|
|
|
+
|
|
|
return $html;
|
|
|
}
|
|
|
|