Gilles has uploaded a new change for review. https://gerrit.wikimedia.org/r/238186
Change subject: Add option to expose original sha1 in thumb url ...................................................................... Add option to expose original sha1 in thumb url Bug: T112546 Change-Id: I545586ff8d0020d00d9faa1dff2d0d9721134452 --- M includes/DefaultSettings.php M includes/filerepo/file/File.php 2 files changed, 18 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/86/238186/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 37429b9..77c6492 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -7714,6 +7714,14 @@ $wgSearchRunSuggestedQueryPercent = 1; /** + * This exposes the original file's sha1 hash in the thumbnail URL. + * + * @var bool + * @since 1.26 + */ +$wgIncludeOriginalSha1InThumbnailUrl = false; + +/** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker * @} diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index f40d216..82e30df 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -940,13 +940,22 @@ * @return string */ public function generateThumbName( $name, $params ) { + global $wgIncludeOriginalSha1InThumbnailUrl; + if ( !$this->getHandler() ) { return null; } $extension = $this->getExtension(); list( $thumbExt, ) = $this->getHandler()->getThumbType( $extension, $this->getMimeType(), $params ); - $thumbName = $this->getHandler()->makeParamString( $params ) . '-' . $name; + $thumbName = $this->getHandler()->makeParamString( $params ); + + if ( $wgIncludeOriginalSha1InThumbnailUrl ) { + $thumbName .= '-' . $this->getSha1(); + } + + $thumbName .= '-' . $name; + if ( $thumbExt != $extension ) { $thumbName .= ".$thumbExt"; } -- To view, visit https://gerrit.wikimedia.org/r/238186 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I545586ff8d0020d00d9faa1dff2d0d9721134452 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gilles <gdu...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits