Skip to content

Commit

Permalink
Suggest appropriate filename when saving a generated preview image. F…
Browse files Browse the repository at this point in the history
…ixes #105.
  • Loading branch information
sbrl committed Sep 11, 2016
1 parent c37ed7c commit 5eb8b7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2941,6 +2941,9 @@ public static function highlight_context($query, $context)

$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.
Expand Down
2 changes: 1 addition & 1 deletion module_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
{
Expand Down
3 changes: 3 additions & 0 deletions modules/feature-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@

$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.
Expand Down

0 comments on commit 5eb8b7f

Please sign in to comment.