From 771701eeefab1a693b325ee2d116915fe5cda087 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sat, 15 Jan 2011 11:20:24 +0000 Subject: [PATCH] Add width parameter to Special:Filepath to allow getting the file path of a thumbnail. Requested by Krinkle for his Wordpress plugin (PhotoCommons) --- includes/specials/SpecialFilepath.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 ); -- 2.20.1