IPreview

interface OCP\IPreview
This class provides functions to render and show thumbnails and previews of files
Implemented by:OC\PreviewManager
Source:lib/public/IPreview.php#47

Constants

EVENT = self::class . : . PreviewRequested
Source:lib/public/IPreview.php#53
Since:9.2.0
Deprecated:22.0.0
MODE_FILL = fill
Source:lib/public/IPreview.php#55
MODE_COVER = cover
Source:lib/public/IPreview.php#56

Methods

public OCP\IPreview::registerProvider($mimeTypeRegex, $callable)
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
Source:

lib/public/IPreview.php#69

Parameters:
  • $mimeTypeRegex (string) Regex with the mime types that are supported by this provider
  • $callable (Closure)
Returns:

void

Since:

8.1.0

public OCP\IPreview::getProviders()
Get all providers
Source:lib/public/IPreview.php#76
Returns:array
Since:8.1.0
public OCP\IPreview::hasProviders()
Does the manager have any providers
Source:lib/public/IPreview.php#83
Returns:bool
Since:8.1.0
public OCP\IPreview::getPreview($file, $width=-1, $height=-1, $crop=false, $mode=\OCP\IPreview::MODE_FILL, $mimeType=null)
Returns a preview of a file
The cache is searched first and if nothing usable was found then a preview is
generated by one of the providers
Source:

lib/public/IPreview.php#102

Parameters:
  • $file (OCP\Files\File)
  • $width (int)
  • $height (int)
  • $crop (bool)
  • $mode (string)
  • $mimeType (string) To force a given mimetype for the file (files_versions needs this)
Returns:

\OCP\Files\SimpleFS\ISimpleFile

Throws:

\OCP\Files\NotFoundException

Throws:

\InvalidArgumentException if the preview would be invalid (in case the original image is invalid)

Throws:

\OCP\Files\NotFoundException

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

public OCP\IPreview::isMimeSupported($mimeType=*)
Returns true if the passed mime type is supported
Source:

lib/public/IPreview.php#110

Parameters:
  • $mimeType (string)
Returns:

bool

Since:

6.0.0

public OCP\IPreview::isAvailable($file)
Check if a preview can be generated for a file
Source:

lib/public/IPreview.php#119

Parameters:
Returns:

bool

Since:

8.0.0

public OCP\IPreview::generatePreviews($file, $specifications, $mimeType=null)
Generates previews of a file
Source:

lib/public/IPreview.php#132

Parameters:
Returns:

\OCP\Files\SimpleFS\ISimpleFile the last preview that was generated

Throws:

\OCP\Files\NotFoundException

Throws:

\InvalidArgumentException if the preview would be invalid (in case the original image is invalid)

Throws:

\OCP\Files\NotFoundException

Throws:

\InvalidArgumentException if the preview would be invalid (in case the original image is invalid)

Since:

19.0.0