From: Roan Kattouw Date: Sat, 15 Jan 2011 11:20:24 +0000 (+0000) Subject: Add width parameter to Special:Filepath to allow getting the file path of a thumbnail... X-Git-Tag: 1.31.0-rc.0~32523 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%2C%22id_auteur=%24connecte%22%29%20.%20%22?a=commitdiff_plain;h=771701eeefab1a693b325ee2d116915fe5cda087;p=lhc%2Fweb%2Fwiklou.git Add width parameter to Special:Filepath to allow getting the file path of a thumbnail. Requested by Krinkle for his Wordpress plugin (PhotoCommons) --- diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php index 419f8408c1..8bb0890c6c 100644 --- a/includes/specials/SpecialFilepath.php +++ b/includes/specials/SpecialFilepath.php @@ -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 );