From 5eb8b7f6b4e1ad96066fcec7feba2718e3556d82 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 11 Sep 2016 18:12:31 +0100 Subject: [PATCH] Suggest appropriate filename when saving a generated preview image. Fixes #105. --- build/index.php | 3 +++ module_index.json | 2 +- modules/feature-upload.php | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build/index.php b/build/index.php index 34b67e6..d92a73f 100755 --- a/build/index.php +++ b/build/index.php @@ -2941,6 +2941,9 @@ register_module([ $filepath = $env->storage_prefix . $pageindex->{$env->page}->uploadedfilepath; $mime_type = $pageindex->{$env->page}->uploadedfilemime; + $shortFilename = substr($filepath, 1 + (strrpos($filepath, '/') !== false ? strrpos($filepath, '/') : -1)); + + header("content-disposition: inline; filename=\"$shortFilename\""); // If the size is set or original, then send (or redirect to) the original image // Also do the same for SVGs if svg rendering is disabled. diff --git a/module_index.json b/module_index.json index 6408740..a2b3cc5 100755 --- a/module_index.json +++ b/module_index.json @@ -77,7 +77,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.", "id": "feature-upload", - "lastupdate": 1472230366, + "lastupdate": 1473613885, "optional": false }, { diff --git a/modules/feature-upload.php b/modules/feature-upload.php index 199308c..b97bc3e 100644 --- a/modules/feature-upload.php +++ b/modules/feature-upload.php @@ -245,6 +245,9 @@ register_module([ $filepath = $env->storage_prefix . $pageindex->{$env->page}->uploadedfilepath; $mime_type = $pageindex->{$env->page}->uploadedfilemime; + $shortFilename = substr($filepath, 1 + (strrpos($filepath, '/') !== false ? strrpos($filepath, '/') : -1)); + + header("content-disposition: inline; filename=\"$shortFilename\""); // If the size is set or original, then send (or redirect to) the original image // Also do the same for SVGs if svg rendering is disabled.