fixed placeholder
This commit is contained in:
parent
43c7832832
commit
f5c980714a
|
|
@ -18,14 +18,16 @@ class ImageService
|
||||||
private $image;
|
private $image;
|
||||||
private $imagePath;
|
private $imagePath;
|
||||||
|
|
||||||
|
const PLACEHOLDER_IMAGE = 'catalog/placeholder.png';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $image
|
* @param string $image
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(string $image)
|
public function __construct(string $image)
|
||||||
{
|
{
|
||||||
$this->image = $image;
|
$this->image = $image ?: self::PLACEHOLDER_IMAGE;
|
||||||
$imagePath = public_path($image);
|
$imagePath = public_path($this->image);
|
||||||
if (!file_exists($imagePath)) {
|
if (!file_exists($imagePath)) {
|
||||||
throw new \Exception("图片不存在");
|
throw new \Exception("图片不存在");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Loading…
Reference in New Issue