\OCPIPreview

This class provides functions to render and show thumbnails and previews of files

Summary

Methods
Constants
registerProvider()
getProviders()
hasProviders()
createPreview()
isMimeSupported()
isAvailable()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

registerProvider()

registerProvider(string  $mimeTypeRegex, \Closure  $callable) : void

In order to improve lazy loading a closure can be registered which will be called in case preview providers are actually requested

$callable has to return an instance of \OCP\Preview\IProvider

Parameters

string $mimeTypeRegex

Regex with the mime types that are supported by this provider

\Closure $callable

getProviders()

getProviders() : array

Get all providers

Returns

array

hasProviders()

hasProviders() : boolean

Does the manager have any providers

Returns

boolean

createPreview()

createPreview(string  $file, integer  $maxX = 100, integer  $maxY = 75, boolean  $scaleUp = false) : \OCP\IImage

Return a preview of a file

Parameters

string $file

The path to the file where you want a thumbnail from

integer $maxX

The maximum X size of the thumbnail. It can be smaller depending on the shape of the image

integer $maxY

The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image

boolean $scaleUp

Scale smaller images up to the thumbnail size or not. Might look ugly

Returns

\OCP\IImage

isMimeSupported()

isMimeSupported(string  $mimeType = '*') : boolean

Returns true if the passed mime type is supported

Parameters

string $mimeType

Returns

boolean

isAvailable()

isAvailable(\OCP\Files\FileInfo  $file) : boolean

Check if a preview can be generated for a file

Parameters

\OCP\Files\FileInfo $file

Returns

boolean