From d8abb038b05757c7e995e2f42529c34f8cb34a61 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Wed, 2 Nov 2022 18:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E7=99=BB=E5=BD=95=20=E5=9B=BE=E7=89=87=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Services/ImageService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beike/Services/ImageService.php b/beike/Services/ImageService.php index 0d36bd0a..2b7b162a 100644 --- a/beike/Services/ImageService.php +++ b/beike/Services/ImageService.php @@ -29,10 +29,6 @@ class ImageService { $this->image = $image ?: self::PLACEHOLDER_IMAGE; $this->imagePath = public_path($this->image); - if (!file_exists($this->imagePath)) { - $this->image = self::PLACEHOLDER_IMAGE; - $this->imagePath = public_path($this->image); - } } @@ -68,6 +64,10 @@ class ImageService public function resize(int $width = 100, int $height = 100): string { try { + if (!file_exists($this->imagePath)) { + $this->image = self::PLACEHOLDER_IMAGE; + $this->imagePath = public_path($this->image); + } if (!file_exists($this->imagePath)) { return ''; }