diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php
index 37cfa50b2..858499daa 100755
--- a/app/Http/Controllers/Api/FileController.php
+++ b/app/Http/Controllers/Api/FileController.php
@@ -525,7 +525,8 @@ class FileController extends AbstractController
Base::makeDir(public_path($tmpPath));
$tmpPath .= md5($text) . "." . $matchs[1][$key];
if (file_put_contents(public_path($tmpPath), base64_decode($text))) {
- $data['content'] = str_replace($matchs[0][$key], 'ext));
}
+
+ /**
+ * 宽
+ * @return int
+ */
+ public function getWidthAttribute()
+ {
+ $this->generateSizeData();
+ return $this->appendattrs['width'];
+ }
+
+ /**
+ * 高
+ * @return int
+ */
+ public function getHeightAttribute()
+ {
+ $this->generateSizeData();
+ return $this->appendattrs['height'];
+ }
+
+ /**
+ * 生成尺寸数据
+ */
+ private function generateSizeData()
+ {
+ if (!isset($this->appendattrs['width'])) {
+ $width = -1;
+ $height = -1;
+ if (in_array($this->ext, ['jpg', 'jpeg', 'gif', 'png'])) {
+ $path = public_path($this->getRawOriginal('path'));
+ [$width, $height] = Cache::remember("File::size-" . md5($path), now()->addDays(7), function () use ($path) {
+ $width = -1;
+ $height = -1;
+ if (file_exists($path)) {
+ $paramet = getimagesize($path);
+ $width = $paramet[0];
+ $height = $paramet[1];
+ }
+ return [$width, $height];
+ });
+ }
+ $this->appendattrs['width'] = $width;
+ $this->appendattrs['height'] = $height;
+ }
+ }
}
diff --git a/resources/assets/js/components/PreviewImage/components/swipe.vue b/resources/assets/js/components/PreviewImage/components/swipe.vue
index 2515dec70..3c9150195 100644
--- a/resources/assets/js/components/PreviewImage/components/swipe.vue
+++ b/resources/assets/js/components/PreviewImage/components/swipe.vue
@@ -54,7 +54,10 @@ export default {
if (item.src) {
item.src = $A.rightDelete(item.src, "_thumb.jpg");
}
- return item
+ if (parseInt(item.width) > 0 && parseInt(item.height) > 0) {
+ return item
+ }
+ item = item.src;
}
return {
html: `