Add width parameter to Special:Filepath to allow getting the file path of a thumbnail...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sat, 15 Jan 2011 11:20:24 +0000 (11:20 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sat, 15 Jan 2011 11:20:24 +0000 (11:20 +0000)
includes/specials/SpecialFilepath.php

index 419f840..8bb0890 100644 (file)
@@ -47,7 +47,16 @@ class SpecialFilepath extends SpecialPage {
                } else {
                        $file = wfFindFile( $title );
                        if ( $file && $file->exists() ) {
-                               $wgOut->redirect( $file->getURL() );
+                               $url = $file->getURL();
+                               $width = $wgRequest->getInt( 'width', -1 );
+                               $height = $wgRequest->getInt( 'height', -1 );
+                               if ( $width != -1 ) {
+                                       $mto = $file->transform( array( 'width' => $width, 'height' => $height ) );
+                                       if ( $mto && !$mto->isError() ) {
+                                               $url = $mto->getURL();
+                                       }
+                               }
+                               $wgOut->redirect( $url );
                        } else {
                                $wgOut->setStatusCode( 404 );
                                $this->showForm( $title );