Home › Forums › Add-ons › Gallery Field › ACF gallery not updating to webp version › Reply To: ACF gallery not updating to webp version
For me not working, don’t know if is because working on staging server. For now using conditions to check if webp image available to add on the website.
<?php
$gallery = get_field('gallery');
if($gallery):
?>
<div class="include-slider">
<?php foreach((array) $gallery as $package_slider):
$package_actual_image_attributes = wp_get_attachment_image_src($package_slider, 'testimonial-thumb');
$package_slider_image_alt = get_post_meta($package_slider, '_wp_attachment_image_alt', true);
if (!$package_image_alt) {
$package_image_alt = get_the_title($package_slider);
}
?>
<div class="slider-item">
<?php if(@getimagesize(($package_actual_image_attributes[0] . '.webp'))): ?>
<img src="<?php echo $package_actual_image_attributes[0] . '.webp'; ?>" alt="<?php echo $package_slider_image_alt; ?>" width="<?php echo $package_actual_image_attributes[1]; ?>" height="<?php echo $package_actual_image_attributes[2]; ?>">
<?php else: ?>
<?php echo wp_get_attachment_image($package_slider, 'testimonial-thumb'); ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.