Exclude particular images loading from CDN

How to use image scaling via the CDN but to exclude the images on the Master slider. I want to use the CDN scaling however when I do the images disappear from the Master Slider on the home page. So is there any way to exclude some of the images from using the CDN.

  • Adam Czajczyk
    • Support Gorilla

    Hello Colin

    I hope you’re well today and thank you for your question!

    While excluding images “out of the box” is not currently possible, it can be done with a small additional code snippet as WP Smush Pro provides a filter hook for this.

    An example code to be added to functions.php file of your site could be like this:

    add_filter( 'smush_skip_image_from_cdn', function( $status, $src, $image ) {
    //compare the $src here and return true to skip

    if ( $src == 'https://domain.com/my-image.jpg' ) {
    return true;
    }

    }, 10, 3 );

    You’d need to replace the example URL above with a real URL of an image to exclude and that should make Smush “skip” loading the image from CDN and make it be loaded locally instead.

    Best regards,

    Adam

  • Nebu John
    • Staff

    Hi Almaz,

    To exclude several images loading from CDN, create an array of URL of the images and iterate as shown in the below-given code:

    add_filter( 'smush_skip_image_from_cdn', function( $status, $src, $image ) {
    //array or URL's
    $url_list = array(
    'https://domain.com/my-image-one.jpg',
    'https://domain.com/my-image-two.jpg',
    );

    foreach($url_list as $url) {
    //compare the $src here and return true to skip
    if ( $src == $url ) {
    return true;
    }
    }
    }, 10, 3 );

    Hope this helps you.

    Kind Regards,

    Nebu John

  • Colin
    • Flash Drive

    Equally, in order to establish the exact url of each image on the slider. I would need to remove the images / layers from the slider and re-add each so that I am able to see the URL.

    Therefore this will mean that I will have to rebuild the entire slider.

  • Predrag Dubajic
    • Support

    Hi Colin,

    I’m afraid that there’s no option to exclude automatically all images from RevSlider but there is no need to recreate the entire slider to get the URLs.
    All you need to do is check your slider in Chrome, right-click on the image and select Inspect, it will open up your slider HTML structure together with image URL so you can get all image URLs that way:

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.