Constants

MAX_DOWNLOAD_SIZE

MAX_DOWNLOAD_SIZE =3145728

Properties

$absolutePath

$absolutePath :

Type

$prefixUrl

$prefixUrl :

Type

$invalidateSeconds

$invalidateSeconds :

Type

Methods

getPluginConstantPrefix()

getPluginConstantPrefix(): string

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

Returns

string

__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

get()

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

Take an URL which needs to be checked if it has cached a thumbnail and set data accordingly:

  • 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

set()

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

See `ImagePreviewCache`.

Additionally, persist all found thumbnails to the database so we can e.g. reuse for List of consents.

Parameters

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

Key is the embed URL

getPrefixUrl()

getPrefixUrl()

Getter.

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

create()

create(string  $uploadsSubfolder = 'embed-thumbnails')

Create the instance.

Parameters

string $uploadsSubfolder

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>