|
|
@@ -62,22 +62,26 @@ class business
|
|
|
$smallImg = self::getSmallImg($imgUrl);
|
|
|
$small = $prefixImgUrl . $smallImg;
|
|
|
$normal = $prefixImgUrl . $imgUrl;
|
|
|
+
|
|
|
/*
|
|
|
- $preImg = $imageRoot . str_replace('/uploads', '', $imgUrl);
|
|
|
- if (file_exists($preImg)) {
|
|
|
- //没有小图则生成小图,兼容旧系统
|
|
|
- if (file_exists($imageRoot . $smallImg) == false) {
|
|
|
- $imgInfo = getimagesize($preImg);
|
|
|
- $width = $imgInfo[0];
|
|
|
- $height = $imgInfo[1];
|
|
|
- //生成小图 300px
|
|
|
- $smallWidth = 300;
|
|
|
- $smallHeight = ceil((300 * $height) / $width);
|
|
|
- $smallFullPathFile = $imageRoot . str_replace('/uploads', '', $smallImg);
|
|
|
- Image::thumbnail($preImg, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
|
|
|
- }
|
|
|
- }
|
|
|
+ $preImg = $imageRoot . str_replace('/uploads', '', $imgUrl);
|
|
|
+ if (file_exists($preImg)) {
|
|
|
+ //没有小图则生成小图,兼容旧系统
|
|
|
+ if (file_exists($imageRoot . $smallImg) == false) {
|
|
|
+ $imgInfo = getimagesize($preImg);
|
|
|
+ $width = isset($imgInfo[0]) ? $imgInfo[0] : 0;
|
|
|
+ $height = isset($imgInfo[1]) ? $imgInfo[1] : 0;
|
|
|
+ if ($width > 0) {
|
|
|
+ //生成小图 300px
|
|
|
+ $smallWidth = 300;
|
|
|
+ $smallHeight = ceil((300 * $height) / $width);
|
|
|
+ $smallFullPathFile = $imageRoot . str_replace('/uploads', '', $smallImg);
|
|
|
+ Image::thumbnail($preImg, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
*/
|
|
|
+
|
|
|
$imgList[] = $normal;
|
|
|
$smallImgList[] = $small;
|
|
|
}
|
|
|
@@ -97,8 +101,8 @@ class business
|
|
|
$prefixImgUrl = Yii::$app->params['imgHost'];
|
|
|
$smallImg = self::getSmallImg($imgUrl);
|
|
|
$small = $prefixImgUrl . $smallImg;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//没有小图的生成小图(兼容旧系统) shish 2020.6.4
|
|
|
$imageRoot = dirUtil::getImgUploadDir();
|
|
|
$preImg = $imageRoot . str_replace('/uploads', '', $imgUrl);
|
|
|
@@ -106,17 +110,19 @@ class business
|
|
|
//没有小图则生成小图,兼容旧系统
|
|
|
if (file_exists($imageRoot . $smallImg) == false) {
|
|
|
$imgInfo = getimagesize($preImg);
|
|
|
- $width = $imgInfo[0];
|
|
|
- $height = $imgInfo[1];
|
|
|
- //生成小图 150px
|
|
|
- $smallWidth = 150;
|
|
|
- $smallHeight = ceil((150 * $height) / $width);
|
|
|
- $smallFullPathFile = $imageRoot . str_replace('/uploads', '', $smallImg);
|
|
|
- Image::thumbnail($preImg, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
|
|
|
+ $width = isset($imgInfo[0]) ? $imgInfo[0] : 0;
|
|
|
+ $height = isset($imgInfo[1]) ? $imgInfo[1] : 0;
|
|
|
+ if ($width > 0) {
|
|
|
+ //生成小图 150px
|
|
|
+ $smallWidth = 150;
|
|
|
+ $smallHeight = ceil((150 * $height) / $width);
|
|
|
+ $smallFullPathFile = $imageRoot . str_replace('/uploads', '', $smallImg);
|
|
|
+ Image::thumbnail($preImg, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
$info['img'] = $small;
|
|
|
return $info;
|
|
|
}
|