]> _ Git - spinepro.git/commitdiff
wip #7368 @3:00
authorsoufiane <soufiane@cubedesigners.com>
Thu, 6 Mar 2025 14:39:35 +0000 (15:39 +0100)
committersoufiane <soufiane@cubedesigners.com>
Thu, 6 Mar 2025 14:39:35 +0000 (15:39 +0100)
wp-content/mu-plugins/cube/src/Elementor/Widgets/BackgroundImage.php
wp-content/mu-plugins/cube/src/Elementor/Widgets/HeaderSlideshow.php
wp-content/themes/CCV/functions.php

index 71289d959fb8766a9086d65431d5c52740634c41..57c618e1e450c6aae465051079b61d32abbbc203 100644 (file)
@@ -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 . '"><div class="bg-image-sizer" style="padding-bottom: ' . $ratio . '"></div></' . $tag . '>';
+        $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 . '"><div class="bg-image-sizer" style="padding-bottom: ' . $ratio . '"></div></' . $tag . '>';
 
     }
 
index ddae7b1f3bd5b08ea1fc5c2bc5cb960acefdfe92..e62635e64fb02e8245929bd24f702f644c4f8ab6 100644 (file)
@@ -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 {
 
                     <?php if (isset($images_mobile[$index]['id'])): ?>
                         <div class="header-slideshow-image-mobile"
-                             style="background-image:url(<?= wp_get_attachment_image_url($images_mobile[$index]['id'], 'full') ?>);">
+                             style="background-image:url(<?= wp_get_attachment_image_url($images_mobile[$index]['id'], 'large') ?>);">
                         </div>
                     <?php endif; ?>
 
                     <div class="header-slideshow-image-desktop"
-                         style="background-image:url(<?= wp_get_attachment_image_url($desktop_image['id'], 'full') ?>);">
+                         style="background-image:url(<?= wp_get_attachment_image_url($desktop_image['id'], 'large') ?>);">
                     </div>
 
                 </div>
index a00f752dc24d1e7b1517c7d8be72aecffa431354..8856d18e407e1d947d09be7101f3a53eee986665 100644 (file)
@@ -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/