\DevOwl\HeadlessContentBlocker\plugins\imagePreviewImagePreviewCache

Provide an interface and mechanism to cache extracted image previews in a folder/database and generate a local URL.

Summary

Methods
Properties
Constants
get()
set()
allowance()
curlInitDownload()
awaitCurlMultiExecution()
extractImageExtension()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

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)

We found a thumbnail and additional data for a fetched URL. Let's cache it and set data accordingly: see `get`.

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