reverted changes

This commit is contained in:
MrRaph_
2025-05-22 19:25:56 +00:00
parent 947b8babdc
commit b495ada832

View File

@@ -240,8 +240,7 @@ function wp_thumbor_transform_url($url, $width = null, $height = null) {
// Détermine l'endpoint : si une clé secrète est renseignée, on signe, sinon on utilise "unsafe" // Détermine l'endpoint : si une clé secrète est renseignée, on signe, sinon on utilise "unsafe"
if ( ! empty($options['thumbor_secret_key']) ) { if ( ! empty($options['thumbor_secret_key']) ) {
$hmac = hash_hmac('sha1', $path_to_sign, $options['thumbor_secret_key'], true); $hmac = hash_hmac('sha1', $path_to_sign, $options['thumbor_secret_key'], true);
// on enlève aussi les '=' de padding pour que Thumbor accepte la signature $encoded_signature = strtr(base64_encode($hmac), '+/', '-_');
$encoded_signature = rtrim(strtr(base64_encode($hmac), '+/', '-_'), '=');
$endpoint = $encoded_signature; $endpoint = $encoded_signature;
} else { } else {
$endpoint = 'unsafe'; $endpoint = 'unsafe';
@@ -298,15 +297,7 @@ function wp_thumbor_output_buffer_callback($buffer) {
foreach ( $srcsetItems as $item ) { foreach ( $srcsetItems as $item ) {
$parts = preg_split('/\s+/', trim($item)); $parts = preg_split('/\s+/', trim($item));
if ( ! empty($parts[0]) && preg_match('/^https?:\/\//', $parts[0]) ) { if ( ! empty($parts[0]) && preg_match('/^https?:\/\//', $parts[0]) ) {
$width = null; $newURL = wp_thumbor_transform_url($parts[0]);
$height = null;
if ( isset($parts[1]) && preg_match('/^(\d+)w$/i', $parts[1], $m) ) {
$width = intval($m[1]);
} elseif ( isset($parts[1]) && preg_match('/^(\d+)h$/i', $parts[1], $m) ) {
$height = intval($m[1]);
}
$newURL = wp_thumbor_transform_url($parts[0], $width, $height);
$newSrcset[] = isset($parts[1]) ? $newURL . ' ' . $parts[1] : $newURL; $newSrcset[] = isset($parts[1]) ? $newURL . ' ' . $parts[1] : $newURL;
} else { } else {
$newSrcset[] = $item; $newSrcset[] = $item;