MediaWiki 1.42.0
MediaTransformOutput Class Reference

Base class for the output of MediaHandler::doTransform() and File::transform(). More...

Inherited by MediaTransformError, and ThumbnailImage.

Collaboration diagram for MediaTransformOutput:

Public Member Functions

 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.
 
 toHtml ( $options=[])
 Fetch HTML for this transform output.
 

Public Attributes

array $responsiveUrls = []
 Associative array mapping optional supplementary image files from pixel density (eg 1.5 or 2) to additional URLs.
 

Protected Member Functions

 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

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

Base class for the output of MediaHandler::doTransform() and File::transform().

Stability: stable
to extend

Definition at line 36 of file MediaTransformOutput.php.

Member Function Documentation

◆ fileIsSource()

MediaTransformOutput::fileIsSource ( )

Check if the output thumbnail is the same as the source.

This can occur if the requested width was bigger than the source.

Returns
bool

Definition at line 182 of file MediaTransformOutput.php.

References isError().

◆ getDescLinkAttribs()

MediaTransformOutput::getDescLinkAttribs ( $title = null,
$params = [] )
Parameters
string | null$title
string | array$paramsQuery parameters to add
Returns
array

Definition at line 267 of file MediaTransformOutput.php.

References $params, and wfArrayToCgi().

Referenced by ThumbnailImage\toHtml().

◆ getExtension()

MediaTransformOutput::getExtension ( )

Get the final extension of the thumbnail.

Returns false for scripted transformations.

Stability: stable
to override
Returns
string|false

Definition at line 94 of file MediaTransformOutput.php.

References FileBackend\extensionFromPath().

◆ getFile()

MediaTransformOutput::getFile ( )
Returns
File

Definition at line 83 of file MediaTransformOutput.php.

◆ getHeight()

MediaTransformOutput::getHeight ( )
Returns
int Height of the output box

Definition at line 76 of file MediaTransformOutput.php.

◆ getLocalCopyPath()

MediaTransformOutput::getLocalCopyPath ( )

Get the path of a file system copy of the thumbnail.

Callers should never write to this path.

Returns
string|false Returns false if there isn't one

Definition at line 192 of file MediaTransformOutput.php.

References $path, isError(), and FileBackend\isStoragePath().

Referenced by streamFileWithStatus().

◆ getStoragePath()

MediaTransformOutput::getStoragePath ( )
Stability: stable
to override
Returns
string|false The permanent thumbnail storage path

Definition at line 112 of file MediaTransformOutput.php.

◆ getUrl()

MediaTransformOutput::getUrl ( )
Stability: stable
to override
Returns
string|false The thumbnail URL

Definition at line 103 of file MediaTransformOutput.php.

◆ getWidth()

MediaTransformOutput::getWidth ( )
Returns
int Width of the output box

Definition at line 69 of file MediaTransformOutput.php.

◆ hasFile()

MediaTransformOutput::hasFile ( )

Check if an output thumbnail file actually exists.

This will return false if there was an error, the thumbnail is to be handled client-side only, or if transformation was deferred via TRANSFORM_LATER. This file may exist as a new file in /tmp, a file in permanent storage, or even refer to the original.

Returns
bool

Definition at line 170 of file MediaTransformOutput.php.

References isError().

◆ isError()

MediaTransformOutput::isError ( )

This will be overridden to return true in error classes.

Returns
bool

Reimplemented in MediaTransformError.

Definition at line 155 of file MediaTransformOutput.php.

Referenced by fileIsSource(), getLocalCopyPath(), and hasFile().

◆ linkWrap()

MediaTransformOutput::linkWrap ( $linkAttribs,
$contents )
protected

Wrap some XHTML text in an anchor tag with the given attributes or, fallback to a span in the absence thereof.

Parameters
array$linkAttribs
string$contents
Returns
string

Definition at line 250 of file MediaTransformOutput.php.

Referenced by ThumbnailImage\toHtml().

◆ setStoragePath()

MediaTransformOutput::setStoragePath ( $storagePath)
Stability: stable
to override
Parameters
string$storagePathThe permanent storage path
Returns
void

Definition at line 122 of file MediaTransformOutput.php.

References $storagePath.

◆ streamFile()

MediaTransformOutput::streamFile ( $headers = [])

Stream the file if there were no errors.

Deprecated
since 1.26, use streamFileWithStatus
Parameters
array$headersAdditional HTTP headers to send on success
Returns
bool Success

Definition at line 238 of file MediaTransformOutput.php.

References streamFileWithStatus().

◆ streamFileWithStatus()

MediaTransformOutput::streamFileWithStatus ( $headers = [])

Stream the file if there were no errors.

Parameters
array$headersAdditional HTTP headers to send on success
Returns
Status
Since
1.27

Definition at line 217 of file MediaTransformOutput.php.

References $success, getLocalCopyPath(), and FileBackend\isStoragePath().

Referenced by streamFile().

◆ toHtml()

MediaTransformOutput::toHtml ( $options = [])
abstract

Fetch HTML for this transform output.

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 Alternate text or caption desc-link Boolean, show a description link file-link Boolean, show a file download link custom-url-link Custom URL to link to custom-title-link Custom Title object to link to 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

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 in MediaTransformError, and ThumbnailImage.

Member Data Documentation

◆ $file

File MediaTransformOutput::$file
protected

Definition at line 43 of file MediaTransformOutput.php.

Referenced by ThumbnailImage\__construct().

◆ $height

int MediaTransformOutput::$height
protected

Image height.

Definition at line 49 of file MediaTransformOutput.php.

Referenced by MediaTransformError\__construct().

◆ $lang

string false MediaTransformOutput::$lang
protected

Language code, false if not set.

Definition at line 61 of file MediaTransformOutput.php.

◆ $page

string false MediaTransformOutput::$page
protected

Definition at line 55 of file MediaTransformOutput.php.

◆ $path

string null false MediaTransformOutput::$path
protected

Filesystem path to the thumb.

Definition at line 58 of file MediaTransformOutput.php.

◆ $responsiveUrls

array MediaTransformOutput::$responsiveUrls = []

Associative array mapping optional supplementary image files from pixel density (eg 1.5 or 2) to additional URLs.

Definition at line 40 of file MediaTransformOutput.php.

Referenced by ThumbnailImage\toHtml().

◆ $storagePath

string false MediaTransformOutput::$storagePath = false
protected

Permanent storage path.

Definition at line 64 of file MediaTransformOutput.php.

Referenced by setStoragePath().

◆ $url

string false MediaTransformOutput::$url
protected

URL path to the thumb.

Definition at line 52 of file MediaTransformOutput.php.

Referenced by ThumbnailImage\__construct().

◆ $width

int MediaTransformOutput::$width
protected

Image width.

Definition at line 46 of file MediaTransformOutput.php.

Referenced by MediaTransformError\__construct().


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