* (bug 19791) Add URL of file source as comment to thumbs (for ImageMagick)
authorRaimond Spekking <raymond@users.mediawiki.org>
Thu, 17 Dec 2009 20:25:55 +0000 (20:25 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Thu, 17 Dec 2009 20:25:55 +0000 (20:25 +0000)
RELEASE-NOTES
includes/filerepo/File.php
includes/media/Bitmap.php

index 815009a..e1502f9 100644 (file)
@@ -298,6 +298,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 21574) Redirects can now have "303 See Other" HTTP status
 * EditPage refactored to allow extensions to derive new edit modes much easier.
 * (bug 21826) Subsections of Special:Version now also have anchors
+* (bug 19791) Add URL of file source as comment to thumbs (for ImageMagick)
 
 === Bug fixes in 1.16 ===
 
index a6169e3..d79a166 100644 (file)
@@ -529,7 +529,7 @@ abstract class File {
         * @return MediaTransformOutput
         */
        function transform( $params, $flags = 0 ) {
-               global $wgUseSquid, $wgIgnoreImageErrors, $wgThumbnailEpoch;
+               global $wgUseSquid, $wgIgnoreImageErrors, $wgThumbnailEpoch, $wgServer;
 
                wfProfileIn( __METHOD__ );
                do {
@@ -539,6 +539,12 @@ abstract class File {
                                break;
                        }
 
+                       // Get the descriptionUrl to embed it as comment into the thumbnail. Bug 19791.
+                       $descriptionUrl =  $this->getDescriptionUrl();
+                       if ( $descriptionUrl ) {
+                               $params['descriptionUrl'] = $wgServer . $descriptionUrl;
+                       }
+
                        $script = $this->getTransformScript();
                        if ( $script && !($flags & self::RENDER_NOW) ) {
                                // Use a script to transform on client request, if possible
index d4a7c35..ddbf33e 100644 (file)
@@ -60,6 +60,7 @@ class BitmapHandler extends ImageHandler {
                $physicalHeight = $params['physicalHeight'];
                $clientWidth = $params['width'];
                $clientHeight = $params['height'];
+               $descriptionUrl = $params['descriptionUrl'];
                $srcWidth = $image->getWidth();
                $srcHeight = $image->getHeight();
                $mimeType = $image->getMimeType();
@@ -154,6 +155,7 @@ class BitmapHandler extends ImageHandler {
                                // or ImageMagick may decide your ratio is wrong and slice off
                                // a pixel.
                                " -thumbnail " . wfEscapeShellArg( "{$physicalWidth}x{$physicalHeight}!" ) .
+                               " -set comment " . wfEscapeShellArg( "File source: {$descriptionUrl}" ) .
                                " -depth 8 $sharpen " .
                                wfEscapeShellArg($dstPath) . " 2>&1";
                        wfDebug( __METHOD__.": running ImageMagick: $cmd\n");