\DevOwl\HeadlessContentBlocker\plugins\imagePreviewFsImagePreviewCache

Provide a file system cache. It is abstract as you should implement your own class for this with missing methods.

Summary

Methods
Properties
Constants
get()
set()
allowance()
curlInitDownload()
awaitCurlMultiExecution()
extractImageExtension()
__construct()
getPrefixUrl()
No public properties found
MAX_DOWNLOAD_SIZE
setBySingleResult()
getCachedMetadata()
getCachedFilesForUrl()
No protected properties found
N/A
No private methods found
$absolutePath
$prefixUrl
$invalidateSeconds
N/A

Constants

MAX_DOWNLOAD_SIZE

MAX_DOWNLOAD_SIZE =3145728

Properties

$absolutePath

$absolutePath :

Type

$prefixUrl

$prefixUrl :

Type

$invalidateSeconds

$invalidateSeconds :

Type

Methods

get()

get(array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail>  $thumbnails)

See `ImagePreviewCache`.

  • MD5 File checksum
  • Cache URL
  • Title
  • Thumbnail width
  • Thumbnail height

If there was an error with the file downloading previously, setError for the Thumbnail.

Parameters

array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail> $thumbnails

Key is the embed URL

allowance()

allowance(array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail>  $thumbnails)

Our image preview processor has found a thumbnail URL for a given website URL. Let's check if using this thumbnail URL is allowed by using `setAllowance`. Why? This could be a license/copyright violation and needs to be consent by the user via a custom UI.

Parameters

array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail> $thumbnails

Key is the embed URL

curlInitDownload()

curlInitDownload(string  $url,string  $target)

Create a curl handle which you could execute or add to a multi-curl instance which downloads a file to a given target on your filesystem.

Parameters

string $url
string $target

awaitCurlMultiExecution()

awaitCurlMultiExecution(resource|\CurlMultiHandle  $mh,array<mixed,\CurlHandle>  $chs)

Execute all queries simultaneously, and continue when all are complete (+ closes the handles).

Parameters

resource|\CurlMultiHandle $mh
array<mixed,\CurlHandle> $chs

extractImageExtension()

extractImageExtension(string  $mime)

Extract an extension for a given image mime-type.

Parameters

string $mime

__construct()

__construct(string  $absolutePath,string  $prefixUrl,integer  $invalidateSeconds)

C'tor.

Parameters

string $absolutePath

Needs to end with /

string $prefixUrl

Needs to end with /, there the cached file name gets appended

integer $invalidateSeconds

Throws

\Exception

Absolute path is not writable or does not exist

getPrefixUrl()

getPrefixUrl()

Getter.

getCachedMetadata()

getCachedMetadata(string  $filename): array|null

Check and parse the metadata file (ending with `.json`).

Parameters

string $filename

The cached filename

Returns

array|null

getCachedFilesForUrl()

getCachedFilesForUrl(string  $hash): array<mixed,string>

Get absolute pathes to already existing files for a given hash (thumbnail ID).

Parameters

string $hash

Returns

array<mixed,string>