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 ''; }