ImagePreviewCache
in package
Provide an interface and mechanism to cache extracted image previews in a folder/database and generate a local URL.
Tags
Table of Contents
Methods
- allowance() : mixed
- 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.
- awaitCurlMultiExecution() : mixed
- Execute all queries simultaneously, and continue when all are complete (+ closes the handles).
- curlInitDownload() : mixed
- 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.
- extractImageExtension() : mixed
- Extract an extension for a given image mime-type.
- get() : mixed
- Take an URL which needs to be checked if it has cached a thumbnail and set data accordingly:
- set() : mixed
- We found a thumbnail and additional data for a fetched URL. Let's cache it and set data accordingly: see `get`.
Methods
allowance()
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.
public
abstract allowance(array<string|int, Thumbnail> $thumbnails) : mixed
Parameters
- $thumbnails : array<string|int, Thumbnail>
-
Key is the embed URL
awaitCurlMultiExecution()
Execute all queries simultaneously, and continue when all are complete (+ closes the handles).
public
awaitCurlMultiExecution(resource|CurlMultiHandle $mh, array<string|int, CurlHandle> $chs) : mixed
Parameters
- $mh : resource|CurlMultiHandle
- $chs : array<string|int, CurlHandle>
curlInitDownload()
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.
public
curlInitDownload(string $url, string $target) : mixed
Parameters
- $url : string
- $target : string
extractImageExtension()
Extract an extension for a given image mime-type.
public
extractImageExtension(string $mime) : mixed
Parameters
- $mime : string
get()
Take an URL which needs to be checked if it has cached a thumbnail and set data accordingly:
public
abstract get(array<string|int, Thumbnail> $thumbnails) : mixed
- 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
- $thumbnails : array<string|int, Thumbnail>
-
Key is the embed URL
set()
We found a thumbnail and additional data for a fetched URL. Let's cache it and set data accordingly: see `get`.
public
abstract set(array<string|int, Thumbnail> $thumbnails) : mixed
Parameters
- $thumbnails : array<string|int, Thumbnail>
-
Key is the embed URL