From 02624d0016d19319d8d1d3c263082690a28ea2c1 Mon Sep 17 00:00:00 2001 From: Jan Gerber Date: Fri, 2 Nov 2012 08:44:22 +0000 Subject: [PATCH] Allow ExtractThumbParameters before local regexp ExtractThumbParameters might be able to extract more params but still match the local regexp. To be able to extract all params, check ExtractThumbParameters first and only fallback to regexp. Change-Id: I26efdec1af5fb2bd5e3cc503f36692d12668b2e2 --- thumb.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/thumb.php b/thumb.php index 362f304b62..b0d72f3df7 100644 --- a/thumb.php +++ b/thumb.php @@ -343,17 +343,18 @@ function wfExtractThumbParams( $uriPath ) { $params['temp'] = 1; } + // Check hooks if parameters can be extracted + // Hooks return false if they manage to *resolve* the parameters + if ( !wfRunHooks( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) { + return $params; // valid thumbnail URL (via extension or config) // Check if the parameters can be extracted from the thumbnail name... - if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) { + } elseif ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) { list( /* all */, $pagefull, $pagenum, $size ) = $matches; $params['width'] = $size; if ( $pagenum ) { $params['page'] = $pagenum; } return $params; // valid thumbnail URL - // Hooks return false if they manage to *resolve* the parameters - } elseif ( !wfRunHooks( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) { - return $params; // valid thumbnail URL (via extension or config) } return null; // not a valid thumbnail URL -- 2.20.1