From 8e6545c43f2a2b35260ddc243ba3f3989976360a Mon Sep 17 00:00:00 2001 From: soufiane Date: Thu, 6 Mar 2025 15:39:35 +0100 Subject: [PATCH] wip #7368 @3:00 --- .../cube/src/Elementor/Widgets/BackgroundImage.php | 4 +++- .../cube/src/Elementor/Widgets/HeaderSlideshow.php | 5 +++-- wp-content/themes/CCV/functions.php | 12 ++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php index 71289d95..57c618e1 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php @@ -183,7 +183,9 @@ class BackgroundImage extends _Base } - echo '<' . $tag . ' class="bg-image ' . $class . '" ' . $attributes . ' style="background-image: url(' . $image['url'] . '); background-position: ' . $bg_position . '">
'; + $image_url = wp_get_attachment_image_url($image['id'], 'large'); + + echo '<' . $tag . ' class="bg-image ' . $class . '" ' . $attributes . ' style="background-image: url(' . $image_url . '); background-position: ' . $bg_position . '">
'; } diff --git a/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php b/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php index ddae7b1f..e62635e6 100644 --- a/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php +++ b/wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php @@ -207,6 +207,7 @@ class HeaderSlideshow extends _Base { // Use first image in gallery to set size of slideshow $image_meta = wp_get_attachment_metadata($images_desktop[0]['id']); + $image_ratio = round($image_meta['height'] / $image_meta['width'] * 100, 2) . '%'; // When this element is present, add a class to the body so the header can be styled differently (transparent background) @@ -225,12 +226,12 @@ class HeaderSlideshow extends _Base {
+ style="background-image:url();">
+ style="background-image:url();">
diff --git a/wp-content/themes/CCV/functions.php b/wp-content/themes/CCV/functions.php index a00f752d..8856d18e 100644 --- a/wp-content/themes/CCV/functions.php +++ b/wp-content/themes/CCV/functions.php @@ -79,6 +79,18 @@ function add_onclick_void($attrs, $item, $args) { } add_filter('nav_menu_link_attributes', 'add_onclick_void', 10, 3); +add_filter('wp_get_attachment_image_src', function($url) { + $newName = str_replace('.','-', $url[0]); + $newName .= ".webp"; + + if(file_exists($_SERVER['DOCUMENT_ROOT'] . $newName)) { + $url[0] = $newName; + } + + return $url; +}); + + /** * Enable sage features * @link https://roots.io/acorn/ -- 2.39.5