MediaWiki master
MediaWiki\Media\ThumbnailImage Class Reference

Media transform output for images. More...

Inherits MediaWiki\Media\MediaTransformOutput.

Collaboration diagram for MediaWiki\Media\ThumbnailImage:

Public Member Functions

 __construct ( $file, $url, $path=false, $parameters=[])
 Get a thumbnail object from a file and parameters.
 
 getAttribs (array $options=[])
 Return extra attributes that should be present on the media tag in the HTML.Takes the same option array as toHtml() (and should be used by the implementation of toHtml()).

Parameters
array$optionsSee options parameter of toHtml()
Returns
array An attribute array

 
 toHtml ( $options=[])
 Return HTML <img ... /> tag for the thumbnail, will include width and height attributes and a blank alt text (as required).
 
- Public Member Functions inherited from MediaWiki\Media\MediaTransformOutput
 fileIsSource ()
 Check if the output thumbnail is the same as the source.
 
 getDescLinkAttribs ( $title=null, $params=[])
 
 getExtension ()
 Get the final extension of the thumbnail.
 
 getFile ()
 
 getHeight ()
 
 getLocalCopyPath ()
 Get the path of a file system copy of the thumbnail.
 
 getStoragePath ()
 
 getUrl ()
 
 getWidth ()
 
 hasFile ()
 Check if an output thumbnail file actually exists.
 
 isError ()
 This will be overridden to return true in error classes.
 
 setStoragePath ( $storagePath)
 
 streamFile ( $headers=[])
 Stream the file if there were no errors.
 
 streamFileWithStatus ( $headers=[])
 Stream the file if there were no errors.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Media\MediaTransformOutput
array $responsiveUrls = []
 Associative array mapping optional supplementary image files from pixel density (eg 1.5 or 2) to additional URLs.
 
- Protected Member Functions inherited from MediaWiki\Media\MediaTransformOutput
 linkWrap ( $linkAttribs, $contents)
 Wrap some XHTML text in an anchor tag with the given attributes or, fallback to a span in the absence thereof.
 
- Protected Attributes inherited from MediaWiki\Media\MediaTransformOutput
File $file
 
int $height
 Image height.
 
string false $lang
 Language code, false if not set.
 
string false $page
 
string null false $path
 Filesystem path to the thumb.
 
string false $storagePath = false
 Permanent storage path.
 
string false $url
 URL path to the thumb.
 
int $width
 Image width.
 

Detailed Description

Media transform output for images.

Definition at line 25 of file ThumbnailImage.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Media\ThumbnailImage::__construct ( $file,
$url,
$path = false,
$parameters = [] )

Get a thumbnail object from a file and parameters.

Parameters
File$file
string$urlURL path to the thumb
string | null | false$pathFilesystem path to the thumb If $path is set to null, the output file is treated as a source copy. If $path is set to false, no output file will be created.
array$parametersAssociative array of parameters
  • 'width' and 'height': Required.
  • 'physicalWidth' and 'physicalHeight': Required, usually set by ImageHandler::normaliseParams or a subclass override.
  • 'page': Optional, for multipage files.
  • 'usePhysicalSize': Optional, used by ApiQueryImageInfo.

Definition at line 41 of file ThumbnailImage.php.

References MediaWiki\Media\MediaTransformOutput\$file, MediaWiki\Media\MediaTransformOutput\$path, and MediaWiki\Media\MediaTransformOutput\$url.

Member Function Documentation

◆ getAttribs()

MediaWiki\Media\ThumbnailImage::getAttribs ( array $options = [])

Return extra attributes that should be present on the media tag in the HTML.Takes the same option array as toHtml() (and should be used by the implementation of toHtml()).

Parameters
array$optionsSee options parameter of toHtml()
Returns
array An attribute array

Reimplemented from MediaWiki\Media\MediaTransformOutput.

Definition at line 83 of file ThumbnailImage.php.

◆ toHtml()

MediaWiki\Media\ThumbnailImage::toHtml ( $options = [])

Return HTML <img ... /> tag for the thumbnail, will include width and height attributes and a blank alt text (as required).

Parameters
array$optionsAssociative array of options. Boolean options should be indicated with a value of true for true, and false or absent for false.
  • alt : HTML alt attribute
  • title : HTML title attribute
  • desc-link : Boolean, show a description link
  • file-link : Boolean, show a file download link
  • valign : vertical-align property, if the output is an inline element
  • img-class : Class applied to the <img> tag, if there is such a tag
  • loading : Specify an explicit browser loading strategy for images and iframes.
  • desc-query : String, description link query params
  • override-width : Override width attribute. Should generally not set
  • override-height : Override height attribute. Should generally not set
  • no-dimensions : Boolean, skip width and height attributes (useful if : set in CSS)
  • custom-url-link : Custom URL to link to
  • custom-title-link : Custom Title object to link to
  • custom-title-link-query : Querystring parameters array, for custom-title-link
  • custom-target-link : Value of the target attribute, for custom-url-link
  • parser-extlink-* : Attributes added by parser for external links:
    • parser-extlink-rel: add rel="nofollow"
    • parser-extlink-target: link target, but overridden by custom-target-link
  • magnify-resource : To set the HTML resource attribute, when necessary

For images, desc-link and file-link are implemented as a click-through. For sounds and videos, they may be displayed in other ways.

Returns
string

Reimplemented from MediaWiki\Media\MediaTransformOutput.

Definition at line 184 of file ThumbnailImage.php.

References MediaWiki\Html\element(), and MediaWiki\MediaWikiServices\getInstance().


The documentation for this class was generated from the following file: