IPreview
in
This class provides functions to render and show thumbnails and previews of files
Tags
Attributes
- #[Consumable]
- $since: '6.0.0'
Table of Contents
Constants
- MODE_COVER : mixed = 'cover'
- MODE_FILL : mixed = 'fill'
Methods
- generatePreviews() : ISimpleFile
- Generates previews of a file
- getPreview() : ISimpleFile
- Returns a preview of a file
- getProviders() : array<string, array<int, ProviderClosure>>
- Get all providers
- hasProviders() : bool
- Does the manager have any providers
- isAvailable() : bool
- Check if a preview can be generated for a file
- isMimeSupported() : bool
- Returns true if the passed mime type is supported
Constants
MODE_COVER
public
mixed
MODE_COVER
= 'cover'
Tags
MODE_FILL
public
mixed
MODE_FILL
= 'fill'
Tags
Methods
generatePreviews()
Generates previews of a file
public
generatePreviews(File $file, array<string|int, mixed> $specifications[, string|null $mimeType = null ]) : ISimpleFile
Parameters
- $file : File
- $specifications : array<string|int, mixed>
- $mimeType : string|null = null
Tags
Return values
ISimpleFile —the last preview that was generated
getPreview()
Returns a preview of a file
public
getPreview(File $file[, int $width = -1 ][, int $height = -1 ][, bool $crop = false ][, IPreview::MODE_* $mode = IPreview::MODE_FILL ][, string $mimeType = null ][, bool $cacheResult = true ]) : ISimpleFile
The cache is searched first and if nothing usable was found then a preview is generated by one of the providers
Parameters
- $file : File
- $width : int = -1
- $height : int = -1
- $crop : bool = false
- $mode : IPreview::MODE_* = IPreview::MODE_FILL
- $mimeType : string = null
-
To force a given mimetype for the file (files_versions needs this)
- $cacheResult : bool = true
-
Whether to cache the preview on the filesystem. Default to true. Can be useful to set to false to limit the amount of stored previews.
Tags
Return values
ISimpleFilegetProviders()
Get all providers
public
getProviders() : array<string, array<int, ProviderClosure>>
Tags
Return values
array<string, array<int, ProviderClosure>>hasProviders()
Does the manager have any providers
public
hasProviders() : bool
Tags
Return values
boolisAvailable()
Check if a preview can be generated for a file
public
isAvailable(FileInfo $file[, string|null $mimeType = null ]) : bool
Parameters
- $file : FileInfo
- $mimeType : string|null = null
-
To force a given mimetype for the file
Tags
Return values
boolisMimeSupported()
Returns true if the passed mime type is supported
public
isMimeSupported([string $mimeType = '*' ]) : bool
Parameters
- $mimeType : string = '*'
-
A glob