From f5c980714afd978054413463d75e8d3863720407 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Tue, 12 Jul 2022 20:04:10 +0800 Subject: [PATCH] fixed placeholder --- beike/Services/ImageService.php | 6 ++++-- .../catalog/{demo/zhanweitu.png => placeholder.png} | Bin 2 files changed, 4 insertions(+), 2 deletions(-) rename public/catalog/{demo/zhanweitu.png => placeholder.png} (100%) diff --git a/beike/Services/ImageService.php b/beike/Services/ImageService.php index cdc51e4c..59615ef3 100644 --- a/beike/Services/ImageService.php +++ b/beike/Services/ImageService.php @@ -18,14 +18,16 @@ class ImageService private $image; private $imagePath; + const PLACEHOLDER_IMAGE = 'catalog/placeholder.png'; + /** * @param string $image * @throws \Exception */ public function __construct(string $image) { - $this->image = $image; - $imagePath = public_path($image); + $this->image = $image ?: self::PLACEHOLDER_IMAGE; + $imagePath = public_path($this->image); if (!file_exists($imagePath)) { throw new \Exception("图片不存在"); } diff --git a/public/catalog/demo/zhanweitu.png b/public/catalog/placeholder.png similarity index 100% rename from public/catalog/demo/zhanweitu.png rename to public/catalog/placeholder.png