Gilles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/120703
Change subject: Have ?download parameter trigger Content-Disposition:
Attachment for thumbs
......................................................................
Have ?download parameter trigger Content-Disposition: Attachment for thumbs
This parameter triggers Content-Disposition: Attachment which
makes the browser download the image instead of displaying it.
This is needed by Media Viewer to allow users to click a button in
order to download an image at a given resolution.
Change-Id: I470a24a09139ac65588312104995e34d97a89b0f
---
M includes/filerepo/file/File.php
M thumb.php
2 files changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/03/120703/1
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index 950baea..c19a51d 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -1066,16 +1066,17 @@
/**
* @param string $thumbName Thumbnail name
+ * @param string $dispositionType Type of disposition (either
"attachment" or "inline")
* @return string Content-Disposition header value
*/
- function getThumbDisposition( $thumbName ) {
+ function getThumbDisposition( $thumbName, $dispositionType = 'inline' )
{
$fileName = $this->name; // file name to suggest
$thumbExt = FileBackend::extensionFromPath( $thumbName );
if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
$fileName .= ".$thumbExt";
}
- return FileBackend::makeContentDisposition( 'inline', $fileName
);
+ return FileBackend::makeContentDisposition( $dispositionType,
$fileName );
}
/**
diff --git a/thumb.php b/thumb.php
index 88aecbd..b0d9f10 100644
--- a/thumb.php
+++ b/thumb.php
@@ -289,8 +289,10 @@
}
}
+ $dispositionType = isset( $params['download'] ) ? 'attachment' :
'inline';
+
// Suggest a good name for users downloading this thumbnail
- $headers[] = "Content-Disposition: {$img->getThumbDisposition(
$thumbName )}";
+ $headers[] = "Content-Disposition: {$img->getThumbDisposition(
$thumbName, $dispositionType )}";
if ( count( $varyHeader ) ) {
$headers[] = 'Vary: ' . implode( ', ', $varyHeader );
--
To view, visit https://gerrit.wikimedia.org/r/120703
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I470a24a09139ac65588312104995e34d97a89b0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits