修复 placeholder 被删除报错

This commit is contained in:
Edward Yang 2022-10-31 17:51:43 +08:00
parent 14be551526
commit 77b3167d36
1 changed files with 4 additions and 0 deletions

View File

@ -68,6 +68,10 @@ class ImageService
public function resize(int $width = 100, int $height = 100): string
{
try {
if (!file_exists($this->imagePath)) {
return '';
}
$extension = pathinfo($this->imagePath, PATHINFO_EXTENSION);
$newImage = 'cache/' . mb_substr($this->image, 0, mb_strrpos($this->image, '.')) . '-' . $width . 'x' . $height . '.' . $extension;