Source masking
By default the source is URL-encoded and visible in the URL. A masker changes that. Pass it as the first argument of Url::create().
Encoding
Section titled “Encoding”EncodingMasker encodes the source as URL-safe Base64.
use SomehowDigital\ImgProxy\Url;use SomehowDigital\ImgProxy\Masker\EncodingMasker;use SomehowDigital\ImgProxy\Option\Width;
$url = Url::create(new EncodingMasker()) ->source('https://example.com/image.jpg') ->options(new Width(100));
$url->build('png');// _/w:100/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZS5qcGc.pngEncoding is not secret: anyone can decode it.
Encryption
Section titled “Encryption”EncryptionMasker encrypts the source with AES-CBC. It needs the hexadecimal key that is configured in imgproxy as IMGPROXY_SOURCE_URL_ENCRYPTION_KEY. The key length selects the cipher: 16 bytes for AES-128, 24 for AES-192 and 32 for AES-256.
use SomehowDigital\ImgProxy\Masker\EncryptionMasker;
$url = Url::create(new EncryptionMasker($key)) ->source('https://example.com/image.jpg') ->options(new Width(100));
$url->build();// _/w:100/enc/<encrypted-source>Every call uses a fresh random initialization vector, so the same URL builds to different results.
A key that is not hexadecimal or has another length throws an InvalidArgumentException.
Custom maskers
Section titled “Custom maskers”Implement MaskerInterface, see the API reference.