Fix for grav#2100 - deleting @2x media files

This commit is contained in:
Andy Miller
2018-07-18 05:25:20 -06:00
parent f75f62012a
commit 9078815c87
2 changed files with 13 additions and 1 deletions

View File

@@ -1826,7 +1826,13 @@ class AdminController extends AdminBaseController
// Remove Extra Files
foreach (scandir($media->path(), SCANDIR_SORT_NONE) as $file) {
if (preg_match("/{$fileParts['filename']}@\d+x\.{$fileParts['extension']}(?:\.meta\.yaml)?$|{$filename}\.meta\.yaml$/", $file)) {
$result = unlink($media->path() . '/' . $file);
$targetPath = $media->path() . '/' . $file;
if ($locator->isStream($targetPath)) {
$targetPath = $locator->findResource($targetPath, true, true);
}
$result = unlink($targetPath);
if (!$result) {
$this->admin->json_response = [