Support

Account

Home Forums Add-ons Gallery Field ACF gallery not updating to webp version

Solved

ACF gallery not updating to webp version

  • ACF gallery not updating the images in webp.

    Using siteground server & their webp service. For post thumbnails(<?php the_post_thumbnail('size'); ?>) webp images are loading fine and automatically on the website but for ACF gallery field(using foreach loop and ID) still loading the old jpg/png images.

    https://staging3.plutontravel.com.cy/packages/summer-singapore-phuket/

    The banner slider been created using ACF Gallery field.

    On this screenshot, is shown how all the images been converted to webp by siteground.
    https://capture.dropbox.com/TYvFFUwhmqkPBsUr

  • Siteground likely has a plugin of some kind that filters the return values when using WP native image functions.

    Images uploaded through an ACF field go through the same process and images uploaded anywhere else in WP using WP functionality to do the work. If this conversion happens on upload then there should be no reason that it would not work with an ACF field.

    This is something that you need to talk to siteground about and see if they have any suggestions.

  • 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; ?>
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.