diff --git a/classes/controller.php b/classes/controller.php index e89f517b..40c6cdfd 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -107,7 +107,23 @@ class AdminController } else { $nonce = $this->grav['uri']->param('admin-nonce'); } - if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) { + + if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) + { + if ($this->task == 'addmedia') { + + $message = sprintf($this->admin->translate('PLUGIN_ADMIN.FILE_TOO_LARGE', null, true), ini_get('post_max_size')); + + //In this case it's more likely that the image is too big than POST can handle. Show message + $this->admin->setMessage($message, 'error'); + $this->admin->json_response = [ + 'status' => 'error', + 'message' => $message + ]; + + return false; + } + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error'); $this->admin->json_response = [ 'status' => 'error', diff --git a/languages/en.yaml b/languages/en.yaml index b9b37c0d..6d7c58ec 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -483,4 +483,5 @@ PLUGIN_ADMIN: FILE_ERROR_ADD: "An error occurred while trying to add the file" FILE_ERROR_UPLOAD: "An error occurred while trying to upload the file" FILE_UNSUPPORTED: "Unsupported file type" - ADD_ITEM: "Add item" \ No newline at end of file + ADD_ITEM: "Add item" + FILE_TOO_LARGE: "The file is too large to be uploaded, maximum allowed is %s according
to your PHP settings. Increase your `post_max_size` PHP setting" \ No newline at end of file