|
MediaWiki master
|
Class encapsulating an image used in an ImageModule. More...
Public Member Functions | |
| __construct ( $name, $module, $descriptor, $basePath, array $variants, $defaultColor=null) | |
| getDataUri (Context $context, $variant, $format) | |
| Get the data: URI that will produce this image. | |
| getExtension ( $format='original') | |
| Get the extension of the image. | |
| getImageData (Context $context, $variant=false, $format=false) | |
| Get actual image data for this image. | |
| getMimeType ( $format='original') | |
| Get the MIME type of the image. | |
| getModule () | |
| Get name of the module this image belongs to. | |
| getName () | |
| Get name of this image. | |
| getPath (Context $context) | |
| Get the path to image file for given context. | |
| getUrl (Context $context, $script, $variant, $format) | |
| Get the load.php URL that will produce this image. | |
| getVariants () | |
| Get the list of variants this image can be converted to. | |
| sendResponseHeaders (Context $context) | |
| Send response headers (using the header() function) that are necessary to correctly serve the image data for this image, as returned by getImageData(). | |
Protected Member Functions | |
| getLangFallbacks (string $lang) | |
| getLocalPath ( $path) | |
| massageSvgPathdata ( $svg) | |
| Massage the SVG image data for converters which don't understand some path data syntax. | |
| rasterize ( $svg) | |
| Convert passed image data, which is assumed to be SVG, to PNG. | |
| variantize (array $variantConf, Context $context) | |
| Convert this image, which is assumed to be SVG, to given variant. | |
Class encapsulating an image used in an ImageModule.
| MediaWiki\ResourceLoader\Image::__construct | ( | $name, | |
| $module, | |||
| $descriptor, | |||
| $basePath, | |||
| array | $variants, | ||
| $defaultColor = null ) |
| string | $name | Self-name of the image as known to ImageModule. |
| string | $module | Self-name of the module containing this image. Used to find the image in the registry e.g. through a load.php url. |
| string | array | $descriptor | Path to image file, or array structure containing paths |
| string | $basePath | Directory to which paths in descriptor refer |
| array | $variants | |
| string | null | $defaultColor | of the base variant |
Definition at line 64 of file Image.php.
References $path, and getLocalPath().
| MediaWiki\ResourceLoader\Image::getDataUri | ( | Context | $context, |
| $variant, | |||
| $format ) |
Get the data: URI that will produce this image.
| Context | $context | Any context |
| string | null | $variant | Variant to get the URI for |
| string | $format | Format to get the URI for, 'original' or 'rasterized' |
Definition at line 253 of file Image.php.
References getImageData(), and getMimeType().
| MediaWiki\ResourceLoader\Image::getExtension | ( | $format = 'original' | ) |
Get the extension of the image.
| string | null | $format | Format to get the extension for, 'original' or 'rasterized' |
Definition at line 202 of file Image.php.
Referenced by getImageData(), getMimeType(), and sendResponseHeaders().
| MediaWiki\ResourceLoader\Image::getImageData | ( | Context | $context, |
| $variant = false, | |||
| $format = false ) |
Get actual image data for this image.
This can be saved to a file or sent to the browser to produce the converted image.
Call getExtension() or getMimeType() with the same $format argument to learn what file type the returned data uses.
| Context | $context | Image context, or any context if $variant and $format given. |
| string | null | false | $variant | Variant to get the data for. Optional; if given, overrides the data from $context. |
| string | false | $format | Format to get the data for, 'original' or 'rasterized'. Optional; if given, overrides the data from $context. |
Definition at line 274 of file Image.php.
References $path, getExtension(), MediaWiki\ResourceLoader\Context\getFormat(), getPath(), MediaWiki\ResourceLoader\Context\getResourceLoader(), MediaWiki\ResourceLoader\Context\getVariant(), rasterize(), and variantize().
Referenced by getDataUri().
|
protected |
|
protected |
| string | FilePath | $path |
Definition at line 188 of file Image.php.
References $path.
Referenced by __construct(), and getPath().
| MediaWiki\ResourceLoader\Image::getMimeType | ( | $format = 'original' | ) |
Get the MIME type of the image.
| string | null | $format | Format to get the MIME type for, 'original' or 'rasterized' |
Definition at line 215 of file Image.php.
References getExtension().
Referenced by getDataUri(), and sendResponseHeaders().
| MediaWiki\ResourceLoader\Image::getModule | ( | ) |
| MediaWiki\ResourceLoader\Image::getName | ( | ) |
Get name of this image.
Definition at line 119 of file Image.php.
Referenced by getUrl(), and sendResponseHeaders().
| MediaWiki\ResourceLoader\Image::getPath | ( | Context | $context | ) |
Get the path to image file for given context.
| Context | $context | Any context |
Definition at line 158 of file Image.php.
References MediaWiki\ResourceLoader\Context\getDirection(), getLangFallbacks(), MediaWiki\ResourceLoader\Context\getLanguage(), and getLocalPath().
Referenced by getImageData(), and variantize().
| MediaWiki\ResourceLoader\Image::getUrl | ( | Context | $context, |
| $script, | |||
| $variant, | |||
| $format ) |
Get the load.php URL that will produce this image.
| Context | $context | Any context |
| string | $script | URL to load.php |
| string | null | $variant | Variant to get the URL for |
| string | $format | Format to get the URL for, 'original' or 'rasterized' |
Definition at line 229 of file Image.php.
References MediaWiki\ResourceLoader\Context\getLanguage(), getModule(), getName(), MediaWiki\ResourceLoader\Context\getResourceLoader(), MediaWiki\ResourceLoader\Context\getSkin(), and wfAppendQuery().
| MediaWiki\ResourceLoader\Image::getVariants | ( | ) |
|
protected |
Massage the SVG image data for converters which don't understand some path data syntax.
This is necessary for rsvg and ImageMagick when compiled with rsvg support. Upstream bug is https://bugzilla.gnome.org/show_bug.cgi?id=620923, fixed 2014-11-10, so this will be needed for a while. (T76852)
| string | $svg | SVG image data |
Definition at line 385 of file Image.php.
Referenced by rasterize().
|
protected |
Convert passed image data, which is assumed to be SVG, to PNG.
| string | $svg | SVG image data |
Definition at line 406 of file Image.php.
References MediaWiki\MediaWikiServices\getInstance(), massageSvgPathdata(), MediaWiki\Media\SvgHandler\rasterize(), MediaWiki\MainConfigNames\SVGConverter, MediaWiki\MainConfigNames\SVGConverterPath, and wfTempDir().
Referenced by getImageData().
| MediaWiki\ResourceLoader\Image::sendResponseHeaders | ( | Context | $context | ) |
Send response headers (using the header() function) that are necessary to correctly serve the image data for this image, as returned by getImageData().
Note that the headers are independent of the language or image variant.
| Context | $context | Image context |
Definition at line 332 of file Image.php.
References getExtension(), getMimeType(), getName(), and Wikimedia\FileBackend\FileBackend\makeContentDisposition().
|
protected |
Convert this image, which is assumed to be SVG, to given variant.
| array | $variantConf | Array with a 'color' key, its value will be used as fill color |
| Context | $context | Image context |
Definition at line 350 of file Image.php.
References getPath().
Referenced by getImageData().