diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d34a0ee..1e629594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ 1. [](#bugfix) * Fixed issue with downloaded package when installing a testing release * Fix #943 allow non admin.super users to change their account information. Allow `admin.super` and `admin.users` to change other users information. + * Handle removing a media file also if it's not a json request. Was not working after https://github.com/getgrav/grav-plugin-admin/commit/6b343365996ce838759d80fa3917d4d994f1aeb4 # v1.2.9 ## 01/18/2017 diff --git a/classes/adminbasecontroller.php b/classes/adminbasecontroller.php index 03975983..e52082dc 100644 --- a/classes/adminbasecontroller.php +++ b/classes/adminbasecontroller.php @@ -876,6 +876,9 @@ class AdminBaseController } $filename = base64_decode($this->grav['uri']->param('route')); + if (!$filename) { + $filename = base64_decode($this->route); + } $file = File::instance($filename); $resultRemoveMedia = false; @@ -895,17 +898,27 @@ class AdminBaseController } if ($resultRemoveMedia && $resultRemoveMediaMeta) { - $this->admin->json_response = [ - 'status' => 'success', - 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL') - ]; + if ($this->grav['uri']->extension() === 'json') { + $this->admin->json_response = [ + 'status' => 'success', + 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL') + ]; + } else { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL'), 'info'); + $this->clearMediaCache(); + $this->setRedirect('/media-manager'); + } return true; } else { - $this->admin->json_response = [ - 'status' => 'success', - 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED') - ]; + if ($this->grav['uri']->extension() === 'json') { + $this->admin->json_response = [ + 'status' => 'success', + 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED') + ]; + } else { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.REMOVE_FAILED'), 'error'); + } return false; }