PreviewManager¶
-
class
OC\
PreviewManager
¶ Source: lib/private/PreviewManager.php#46 Implements: OCP\IPreview
Properties¶
-
protected static property
OC\PreviewManager::$
config
¶ Source: lib/private/PreviewManager.php#48 Type: \OCP\IConfig
-
protected static property
OC\PreviewManager::$
rootFolder
¶ Source: lib/private/PreviewManager.php#51 Type: \OCP\Files\IRootFolder
-
protected static property
OC\PreviewManager::$
appData
¶ Source: lib/private/PreviewManager.php#54 Type: \OCP\Files\IAppData
-
protected static property
OC\PreviewManager::$
eventDispatcher
¶ Source: lib/private/PreviewManager.php#57 Type: \Symfony\Component\EventDispatcher\EventDispatcherInterface
-
protected static property
OC\PreviewManager::$
providerListDirty
¶ Source: lib/private/PreviewManager.php#66 Type: bool
-
protected static property
OC\PreviewManager::$
registeredCoreProviders
¶ Source: lib/private/PreviewManager.php#69 Type: bool
-
protected static property
OC\PreviewManager::$
providers
¶ Source: lib/private/PreviewManager.php#72 Type: array
-
protected static property
OC\PreviewManager::$
mimeTypeSupportMap
¶ Source: lib/private/PreviewManager.php#75 Type: array mime type => support status
-
protected static property
OC\PreviewManager::$
defaultProviders
¶ Source: lib/private/PreviewManager.php#78 Type: array
-
protected static property
OC\PreviewManager::$
userId
¶ Source: lib/private/PreviewManager.php#81 Type: string
Methods¶
-
public
OC\PreviewManager::
__construct
($config, $rootFolder, $appData, $eventDispatcher, $helper, $userId)¶ - PreviewManager constructor.
Source: Parameters: - $config (
OCP\IConfig
) - $rootFolder (
OCP\Files\IRootFolder
) - $appData (
OCP\Files\IAppData
) - $eventDispatcher (
Symfony\Component\EventDispatcher\EventDispatcherInterface
) - $userId (string)
- $config (
-
public
OC\PreviewManager::
registerProvider
($mimeTypeRegex, $callable)¶ - In order to improve lazy loading a closure can be registered which will becalled in case preview providers are actually requested$callable has to return an instance of \OCP\Preview\IProvider or \OCP\Preview\IProviderV2
Source: Parameters: - $mimeTypeRegex (string) Regex with the mime types that are supported by this provider
- $callable (
Closure
)
Returns: void
-
public
OC\PreviewManager::
getProviders
()¶ - Get all providers
Source: lib/private/PreviewManager.php#132 Returns: array
-
public
OC\PreviewManager::
hasProviders
()¶ - Does the manager have any providers
Source: lib/private/PreviewManager.php#151 Returns: bool
-
public
OC\PreviewManager::
getPreview
($file, $width=-1, $height=-1, $crop=false, $mode=\OCP\IPreview::MODE_FILL, $mimeType=null)¶ - Returns a preview of a fileThe cache is searched first and if nothing usable was found then a preview isgenerated by one of the providers
Source: Parameters: - $file (
OCP\Files\File
) - $width (int)
- $height (int)
- $crop (bool)
- $mode (string)
- $mimeType (string)
Returns: Throws: Throws: \InvalidArgumentException
if the preview would be invalid (in case the original image is invalid)Throws: Throws: \InvalidArgumentException
if the preview would be invalid (in case the original image is invalid)Since: 11.0.0 - \InvalidArgumentException was added in 12.0.0
- $file (
-
public
OC\PreviewManager::
generatePreviews
($file, $specifications, $mimeType=null)¶ - Generates previews of a file
Source: Parameters: - $file (
OCP\Files\File
) - $specifications (array)
- $mimeType (string)
Returns: \OCP\Files\SimpleFS\ISimpleFile
the last preview that was generatedThrows: Throws: \InvalidArgumentException
if the preview would be invalid (in case the original image is invalid)Throws: Throws: \InvalidArgumentException
if the preview would be invalid (in case the original image is invalid)Since: 19.0.0
- $file (
-
public
OC\PreviewManager::
isMimeSupported
($mimeType=*)¶ - returns true if the passed mime type is supported
Source: Parameters: - $mimeType (string)
Returns: bool
-
public
OC\PreviewManager::
isAvailable
($file)¶ - Check if a preview can be generated for a file
Source: Parameters: - $file (
OCP\Files\FileInfo
)
Returns: bool
- $file (
-
protected
OC\PreviewManager::
getEnabledDefaultProvider
()¶ - List of enabled default providersThe following providers are enabled by default:- OC\Preview\PNG- OC\Preview\JPEG- OC\Preview\GIF- OC\Preview\BMP- OC\Preview\HEIC- OC\Preview\XBitmap- OC\Preview\MarkDown- OC\Preview\MP3- OC\Preview\TXTThe following providers are disabled by default due to performance or privacy concerns:- OC\Preview\Font- OC\Preview\Illustrator- OC\Preview\Movie- OC\Preview\MSOfficeDoc- OC\Preview\MSOffice2003- OC\Preview\MSOffice2007- OC\Preview\OpenDocument- OC\Preview\PDF- OC\Preview\Photoshop- OC\Preview\Postscript- OC\Preview\StarOffice- OC\Preview\SVG- OC\Preview\TIFF
Source: lib/private/PreviewManager.php#304 Returns: array
-
protected
OC\PreviewManager::
registerCoreProvider
($class, $mimeType, $options=[])¶ - Register the default providers (if enabled)
Source: Parameters: - $class (string)
- $mimeType (string)
-
protected
OC\PreviewManager::
registerCoreProviders
()¶ - Register the default providers (if enabled)
Source: lib/private/PreviewManager.php#351