MediaWiki  1.23.2
thumb.php File Reference

PHP script to stream out an image thumbnail. More...

Go to the source code of this file.

Functions

 wfExtractThumbParams ( $file, $params)
 Convert a thumbnail name (122px-foo.png) to parameters, using file handler. More...
 
 wfExtractThumbRequestInfo ( $thumbRel)
 Convert pathinfo type parameter, into normal request parameters. More...
 
 wfStreamThumb (array $params)
 Stream a thumbnail specified by parameters. More...
 
 wfThumbAttemptKey (File $img, $thumbName)
 
 wfThumbError ( $status, $msg)
 Output a thumbnail generation error message. More...
 
 wfThumbHandle404 ()
 Handle a thumbnail request via thumbnail file URL. More...
 
 wfThumbHandleRequest ()
 Handle a thumbnail request via query parameters. More...
 
 wfThumbIncrAttemptFailures (File $img, $thumbName)
 
 wfThumbIsAttemptThrottled (File $img, $thumbName, $limit)
 

Variables

 $factory = wfGetLBFactory()
 
 $wgTrivialMimeDetection = true
 
if(defined( 'THUMB_HANDLER')) else
 
const MW_NO_OUTPUT_COMPRESSION 1
 

Detailed Description

PHP script to stream out an image thumbnail.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Definition in file thumb.php.

Function Documentation

◆ wfExtractThumbParams()

wfExtractThumbParams (   $file,
  $params 
)

Convert a thumbnail name (122px-foo.png) to parameters, using file handler.

Parameters
File$fileFile object for file in question.
$paramArray Array of parameters so far.
Returns
Array parameters array with more parameters.

Definition at line 448 of file thumb.php.

References $file, $matches, $params, $size, array(), list, wfDeprecated(), and wfRunHooks().

Referenced by wfStreamThumb().

◆ wfExtractThumbRequestInfo()

wfExtractThumbRequestInfo (   $thumbRel)

Convert pathinfo type parameter, into normal request parameters.

So for example, if the request was redirected from /w/images/thumb/a/ab/Foo.png/120px-Foo.png. The $thumbRel parameter of this function would be set to "a/ab/Foo.png/120px-Foo.png". This method is responsible for turning that into an array with the folowing keys:

  • f => the filename (Foo.png)
  • rel404 => the whole thing (a/ab/Foo.png/120px-Foo.png)
  • archived => 1 (If the request is for an archived thumb)
  • temp => 1 (If the file is in the "temporary" zone)
  • thumbName => the thumbnail name, including parameters (120px-Foo.png)

Transform specific parameters are set later via wfExtractThumbParams().

Parameters
$thumbRelString Thumbnail path relative to the thumb zone
Returns
Array|null associative params array or null

Definition at line 410 of file thumb.php.

References $params, array(), list, and RepoGroup\singleton().

Referenced by wfThumbHandle404().

◆ wfStreamThumb()

wfStreamThumb ( array  $params)

Stream a thumbnail specified by parameters.

Parameters
$paramsArray List of thumbnailing parameters. In addition to parameters passed to the MediaHandler, this may also includes the keys: f (for filename), archived (if archived file), temp (if temp file), w (alias for width), p (alias for page), r (ignored; historical), rel404 (path for render on 404 to verify hash path correct), thumbName (thumbnail name to potentially extract more parameters from e.g. 'lossy-page1-120px-Foo.tiff' would add page, lossy and width to the parameters)
Returns
void

Definition at line 105 of file thumb.php.

References $e, $params, $response, $section, $title, $user, are, array(), based, false, User\getGroupPermissions(), RequestContext\getMain(), HttpStatus\getMessage(), global, however, Title\makeTitleSafe(), name, NS_FILE, on, PROTO_CURRENT, File\RENDER_NOW, RepoGroup\singleton(), text, File\THUMB_FULL_NAME, TS_UNIX, wfExpandUrl(), wfExtractThumbParams(), wfLocalFile(), wfMessage(), wfRestoreWarnings(), wfSuppressWarnings(), wfThumbError(), wfThumbIncrAttemptFailures(), wfThumbIsAttemptThrottled(), wfTimestamp(), and will.

Referenced by wfThumbHandle404(), and wfThumbHandleRequest().

◆ wfThumbAttemptKey()

wfThumbAttemptKey ( File  $img,
  $thumbName 
)
Parameters
File$img
string$thumbName
Returns
string

Definition at line 384 of file thumb.php.

References File\getName(), File\getRepo(), global, and wfMemcKey().

Referenced by wfThumbIncrAttemptFailures(), and wfThumbIsAttemptThrottled().

◆ wfThumbError()

wfThumbError (   $status,
  $msg 
)

Output a thumbnail generation error message.

Parameters
$statusinteger
$msgstring
Returns
void

Definition at line 506 of file thumb.php.

References $debug, global, title, and wfHostname().

Referenced by wfStreamThumb(), and wfThumbHandle404().

◆ wfThumbHandle404()

wfThumbHandle404 ( )

Handle a thumbnail request via thumbnail file URL.

Returns
void

Definition at line 64 of file thumb.php.

References $matches, $params, $wgArticlePath, WebRequest\getPathInfo(), global, RepoGroup\singleton(), wfExtractThumbRequestInfo(), wfStreamThumb(), and wfThumbError().

◆ wfThumbHandleRequest()

wfThumbHandleRequest ( )

Handle a thumbnail request via query parameters.

Returns
void

Definition at line 51 of file thumb.php.

References $params, and wfStreamThumb().

◆ wfThumbIncrAttemptFailures()

wfThumbIncrAttemptFailures ( File  $img,
  $thumbName 
)
Parameters
File$img
string$thumbName

Definition at line 368 of file thumb.php.

References $wgMemc, global, and wfThumbAttemptKey().

Referenced by wfStreamThumb().

◆ wfThumbIsAttemptThrottled()

wfThumbIsAttemptThrottled ( File  $img,
  $thumbName,
  $limit 
)
Parameters
File$img
string$thumbName
int$limit
Returns
int|bool

Definition at line 358 of file thumb.php.

References $limit, $wgMemc, global, and wfThumbAttemptKey().

Referenced by wfStreamThumb().

Variable Documentation

◆ $factory

$factory = wfGetLBFactory()

Definition at line 40 of file thumb.php.

◆ $wgTrivialMimeDetection

$wgTrivialMimeDetection = true

Definition at line 28 of file thumb.php.

Referenced by StreamFile\contentTypeFromPath().

◆ else

if (defined('THUMB_HANDLER')) else
Initial value:

Definition at line 33 of file thumb.php.

◆ MW_NO_OUTPUT_COMPRESSION

const MW_NO_OUTPUT_COMPRESSION 1

Definition at line 24 of file thumb.php.

wfThumbHandleRequest
wfThumbHandleRequest()
Handle a thumbnail request via query parameters.
Definition: thumb.php:51