mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-21 20:48:00 +01:00
Fixed an issue with Image::clearExisting
Now no longer deletes original image regardless of paramter
This commit is contained in:
parent
e502785c2d
commit
e6103bbd54
2 changed files with 4 additions and 6 deletions
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue