diff --git a/app/Console/Commands/RebuildImages.php b/app/Console/Commands/RebuildImages.php index 51c6a9bf..d2fb2048 100644 --- a/app/Console/Commands/RebuildImages.php +++ b/app/Console/Commands/RebuildImages.php @@ -41,7 +41,7 @@ class RebuildImages extends Command { $images = Image::all(); foreach ($images as $image) { - $this->info("Regenerating images for ".$image->filename); + $this->info("Regenerating images for id:".$image->id. " (".$image->filename.")"); $image->clearExisting(); $originalFile = new File($image->getFile(Image::ORIGINAL)); diff --git a/app/Models/Image.php b/app/Models/Image.php index 46a10b70..253ce857 100644 --- a/app/Models/Image.php +++ b/app/Models/Image.php @@ -201,12 +201,10 @@ class Image extends Model public function clearExisting($includeOriginal = false) { $files = scandir($this->getDirectory()); $filePrefix = $this->id.'_'; + $originalName = $filePrefix.Image::$ImageTypes[Image::ORIGINAL]['name']; - $files = array_filter($files, function($file) use ($includeOriginal, $filePrefix) { - $originalName = Image::$ImageTypes[Image::ORIGINAL]['name']; - - if ($file === $filePrefix.$originalName && !$includeOriginal) - return false; + $files = array_filter($files, function($file) use ($originalName, $includeOriginal, $filePrefix) { + if (Str::startsWith($file,$originalName) && !$includeOriginal) return false; else return (Str::startsWith($file, $filePrefix)); });