}
- 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 . '>';
}
// 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)
<?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>
}
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/