From f5cccb67a84f9aec51e5e383d72ae900988850fb Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Sat, 15 Nov 2008 01:29:52 +0000 Subject: [PATCH] Configure extension: * Let users enter an image name for the logo, and then click a button to have it converted to a thumbnail URL. --- includes/AjaxFunctions.php | 15 +++++++++++++++ includes/DefaultSettings.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 2468909d65..9ee354534c 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -126,3 +126,18 @@ function wfAjaxWatch($pagename = "", $watch = "") { return ''.wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); } } + +/** + * Called in some places (currently just extensions) + * to get the thumnail URL for a given file at a given resolution. + */ +function wfAjaxGetThumbnailUrl( $file, $width, $height ) { + $file = wfFindFile( $file ); + + if ( !$file || !$file->exists() ) + return null; + + $url = $file->getThumbnail( $width, $height )->url; + + return $url; +} \ No newline at end of file diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 354712d78c..d0f918d0ba 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3301,7 +3301,7 @@ $wgUseAjax = true; * List of Ajax-callable functions. * Extensions acting as Ajax callbacks must register here */ -$wgAjaxExportList = array( ); +$wgAjaxExportList = array( 'wfAjaxGetThumbnailUrl' ); /** * Enable watching/unwatching pages using AJAX. -- 2.20.1