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();
|
$images = Image::all();
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
$this->info("Regenerating images for ".$image->filename);
|
$this->info("Regenerating images for id:".$image->id. " (".$image->filename.")");
|
||||||
$image->clearExisting();
|
$image->clearExisting();
|
||||||
|
|
||||||
$originalFile = new File($image->getFile(Image::ORIGINAL));
|
$originalFile = new File($image->getFile(Image::ORIGINAL));
|
||||||
|
|
|
@ -201,12 +201,10 @@ class Image extends Model
|
||||||
public function clearExisting($includeOriginal = false) {
|
public function clearExisting($includeOriginal = false) {
|
||||||
$files = scandir($this->getDirectory());
|
$files = scandir($this->getDirectory());
|
||||||
$filePrefix = $this->id.'_';
|
$filePrefix = $this->id.'_';
|
||||||
|
$originalName = $filePrefix.Image::$ImageTypes[Image::ORIGINAL]['name'];
|
||||||
|
|
||||||
$files = array_filter($files, function($file) use ($includeOriginal, $filePrefix) {
|
$files = array_filter($files, function($file) use ($originalName, $includeOriginal, $filePrefix) {
|
||||||
$originalName = Image::$ImageTypes[Image::ORIGINAL]['name'];
|
if (Str::startsWith($file,$originalName) && !$includeOriginal) return false;
|
||||||
|
|
||||||
if ($file === $filePrefix.$originalName && !$includeOriginal)
|
|
||||||
return false;
|
|
||||||
else return (Str::startsWith($file, $filePrefix));
|
else return (Str::startsWith($file, $filePrefix));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue