This commit is contained in:
2025-03-05 16:14:01 +01:00
parent e2073ac49b
commit 486aded0e4

View File

@@ -247,6 +247,9 @@ function wp_thumbor_transform_url($url, $width = null, $height = null) {
$final_url = $thumbor_base_url . '/' . $endpoint . '/' . $path_to_sign;
wp_thumbor_log("Transformation de l'URL : $url en $final_url");
// Méthode 1 : Encodage manuel des parenthèses pour éviter que esc_url tronque l'URL
//$final_url = str_replace(['(', ')'], ['%28', '%29'], $final_url);
return $final_url;
}
@@ -324,7 +327,7 @@ function wp_thumbor_output_buffer_callback($buffer) {
continue;
}
// Traitement du style inline pour les background-images
$style = $element->getAttribute('style');
/**$style = $element->getAttribute('style');
if ( ! empty($style) ) {
$newStyle = preg_replace_callback('/url\((["\']?)(https?:\/\/[^"\'\)]+)\1\)/i', function($matches) {
$url = $matches[2];
@@ -332,7 +335,8 @@ function wp_thumbor_output_buffer_callback($buffer) {
return 'url("' . $transformed . '")';
}, $style);
$element->setAttribute('style', $newStyle);
}
}
**/
// Traitement des attributs data-image et data-src pour les backgrounds
if ( $element->hasAttribute('data-image') ) {
$dataImage = $element->getAttribute('data-image');
@@ -346,12 +350,13 @@ function wp_thumbor_output_buffer_callback($buffer) {
$element->setAttribute('data-src', wp_thumbor_transform_url($dataSrc));
}
}
if ( $element->hasAttribute('data-bg') ) {
// Traitement pour l'attribut data-bg
/*if ( $element->hasAttribute('data-bg') ) {
$dataBg = $element->getAttribute('data-bg');
if ( preg_match('/^https?:\/\//', $dataBg) ) {
$element->setAttribute('data-bg', wp_thumbor_transform_url($dataBg));
}
}
}*/
}
// Traitement spécifique pour les liens preload d'image dans le <head>