Documentation

WordPressImagePreviewCache extends FsImagePreviewCache
in package
Uses UtilsProvider

Create a filesystem cache for your image preview / thumbnails.

Table of Contents

Constants

MAX_DOWNLOAD_SIZE  = 3145728

Properties

$absolutePath  : mixed
$invalidateSeconds  : mixed
$prefixUrl  : mixed

Methods

__construct()  : mixed
C'tor.
allowance()  : mixed
See `ImagePreviewCache`.
awaitCurlMultiExecution()  : mixed
Execute all queries simultaneously, and continue when all are complete (+ closes the handles).
create()  : mixed
Create the instance.
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:
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getPrefixUrl()  : mixed
Getter.
set()  : mixed
See `ImagePreviewCache`.
getCachedFilesForUrl()  : array<string|int, string>
Get absolute pathes to already existing files for a given hash (thumbnail ID).
getCachedMetadata()  : array<string|int, mixed>|null
Check and parse the metadata file (ending with `.json`).
setBySingleResult()  : mixed
Single process a result within `$this::set()`.

Constants

Properties

Methods

__construct()

C'tor.

public __construct(string $absolutePath, string $prefixUrl[, int $invalidateSeconds = 0 ]) : mixed
Parameters
$absolutePath : string

Needs to end with /

$prefixUrl : string

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

$invalidateSeconds : int = 0
Tags
throws
Exception

Absolute path is not writable or does not exist

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>

create()

Create the instance.

public static create([string $uploadsSubfolder = 'embed-thumbnails' ]) : mixed
Parameters
$uploadsSubfolder : string = 'embed-thumbnails'

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

getPluginConstantPrefix()

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

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

set()

See `ImagePreviewCache`.

public set(array<string|int, Thumbnail$thumbnails) : mixed

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

Parameters
$thumbnails : array<string|int, Thumbnail>

Key is the embed URL

getCachedFilesForUrl()

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

protected getCachedFilesForUrl(string $hash) : array<string|int, string>
Parameters
$hash : string
Return values
array<string|int, string>

getCachedMetadata()

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

protected getCachedMetadata(string $filename) : array<string|int, mixed>|null
Parameters
$filename : string

The cached filename

Return values
array<string|int, mixed>|null

setBySingleResult()

Single process a result within `$this::set()`.

protected setBySingleResult(array<string|int, mixed> $handle, Thumbnail $thumbnail) : mixed
Parameters
$handle : array<string|int, mixed>
$thumbnail : Thumbnail

        
On this page

Search results