mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-02-02 11:34:20 +02:00
Update PHP URL generation example (#66)
String interpolation is a little easier to read and understand as there's no back-and-forth between string format and arguments. Matches JS version: https://github.com/DarthSim/imgproxy/blob/master/examples/signature.js#L27
This commit is contained in:
parent
96249406f4
commit
09bfd44c55
@ -23,7 +23,7 @@ $extension = 'png';
|
|||||||
$url = 'http://img.example.com/pretty/image.jpg';
|
$url = 'http://img.example.com/pretty/image.jpg';
|
||||||
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
|
$encodedUrl = rtrim(strtr(base64_encode($url), '+/', '-_'), '=');
|
||||||
|
|
||||||
$path = sprintf("/%s/%d/%d/%s/%d/%s.%s", $resize, $width, $height, $gravity, $enlarge, $encodedUrl, $extension);
|
$path = "/{$resize}/{$width}/{$height}/{$gravity}/{$enlarge}/{$encodedUrl}.{$extension}";
|
||||||
|
|
||||||
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');
|
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $saltBin.$path, $keyBin, true)), '+/', '-_'), '=');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user