• Resolved modernwp

    (@modernwp)


    Hi there

    I have one image on a page which is being weird, possibly something to do with .png transparency issues. It works fine on local, not on the live / jetpack-served site.

    I am following this useful instruction which seems to be a function to remove image processing per-page: https://jetpack.com/2020/05/14/jetpack-hooks-control-jetpack-cdn/

    I added this function to functions.php

    //disable Jetpack in certain areas

    function jetpackblog_studios() {
    if ( is_page( ‘studios’ ) ) {
    add_filter( ‘jetpack_photon_skip_image’, ‘__return_true’);
    }
    }

    add_action( ‘wp’, ‘jetpackblog_studios’ );

    But it doesnt seem to work? Any ideas what I am doing wrong? Does this hook still work?

    And —?how woulf I target just one image?

    thanks for looking

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @modernwp

    I see that you’ve already linked the support document that lists the different options to exclude images by pages/posts or just an image, but I’ll copy the steps for you below:

    If you want to exclude a specific image, here’s the snippet to add:

    function my_photon_exception( $val, $src, $tag ) {
            if ( $src == 'YOUR_IMAGE_URL' ) {
                    return true;
            }
            return $val;
    }
    add_filter( 'jetpack_photon_skip_image', 'my_photon_exception', 10, 3 );

    Important: Be sure to update the variable (YOUR_IMAGE_URL) to the direct URL of your image.

    I’d suggest removing the code from your functions.php file, and try with a Snippet code plugin such as this one.

    Let us know how this goes.

    Best,

    Thread Starter modernwp

    (@modernwp)

    Thanks for looking at this… the function is definitely in and targeting the right page, but Jetpack is still serving the images… How can I debug this, could it be something to do with how the image is handled in my page template? Or possibly a page caching / Cloudflare issue?

    I am using Timber, the image I want to stop Jetpack deploying is handled like this… (also shown on this link, the top-right building image) https://millco.co.uk/studios/

    {% set imageS = Image(post.feature_image) %}
    <img class="object-cover w-screen h-screen " src="{{ imageS.src }}" alt="{{ imageS.alt }}"/>

    Which leads me to ask — ideally I would target images to skip Jetpack by CLASS —?not individually or by page or post ID, is this possible?

    thanks!

    • This reply was modified 3 years, 1 month ago by modernwp.
    • This reply was modified 3 years, 1 month ago by modernwp.
    Plugin Contributor Dan (a11n)

    (@drawmyface)

    Hi there

    Can you try using the page ID instead of the slug to see if that makes a difference? If not, can you show us a screenshot of your code so we can check for any issues?

    Ideally I would target images to skip Jetpack by CLASS — not individually or by page or post ID, is this possible?

    Currently there’s no easy way to do that, but I’ve flagged this to our developers here for consideration:
    https://github.com/Automattic/jetpack/issues/21447

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bypass Jetpack image processing for one image only’ is closed to new replies.