Skip to content

Commit

Permalink
Fixed delete image issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
todstoychev committed Nov 11, 2015
1 parent 8740a3f commit d0e7aed
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Handler/DeleteImageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public function deleteImageSizes($context, $fileName)
$contextPath = public_path($this->getUploadsPath() . '/' . $context);

foreach ($this->getContextValues($context) as $key => $value) {
$image = $contextPath . '/' . $context . '/' . $fileName;
$image = $contextPath . '/' . $key . '/' . $fileName;

is_file($image) ? unlink($image) : null;
}
}

/**
* Copletely deletes an image
* Completely deletes an image
*
* @param string $context
* @param string $fileName
Expand All @@ -42,8 +42,12 @@ public function deleteImage($context, $fileName)
{
$this->deleteImageSizes($context, $fileName);

$originalImage = public_path($this->getUploadsPath() . '/' . $context . '/' . $fileName);
$fileName = preg_replace('/\.[a-z]{3,4}/', '', $fileName);

is_file($originalImage) ? unlink($originalImage) : null;
$path = public_path($this->getUploadsPath() . '/' . $context);

foreach (glob($path . '/' . $fileName . '*') as $file) {
unlink($file);
}
}
}

0 comments on commit d0e7aed

Please sign in to comment.