apply_filters ( 'jetpack_photon_skip_image', bool false, string $src, string $tag )

Allow specific images to be skipped by Photon.

Source file: class.photon.php

View in GitHub

Parameters

false

(bool) false Should Photon ignore this image. Default to false.

$src

(string) Image URL.

$tag

(string) Image Tag (Image HTML output).


Changelog

Since: Jetpack 2.0.3


Notes

To exclude an entire post or page from using Photon, you can modify this snippet to fit your needs and add it to your theme’s functions.php or a core functionality plugin:

function no_photon_by_page() {
  if ( is_page( 2 ) ) {
    add_filter( 'jetpack_photon_skip_image', '__return_true');
  }
}

add_action('wp', 'no_photon_by_page');

In this example, Photon won’t be used on the page with the ID of 2, but you can use any of the WordPress Conditional Functions.

If you’d like to exclude an image from being cached and served by Photon, you can add the following code to your theme’s functions.php file:

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 );

To exclude images from a specific domain, you can use the following code:

function htdat_photon_exception_for_domain ( $val, $src, $tag ) {
        $parse = parse_url( $src ); 
        $img_domain = $parse[ 'host' ]; 
        
        // specify the domain you want to exclude here. Note: www and non-www are different
        if ( $img_domain == 'domain.com' ) { 
                return true;
        }

        return $val;
}
add_filter( 'jetpack_photon_skip_image', 'htdat_photon_exception_for_domain', 10, 3 );

Leave a Reply to heri wahyudianto Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments

  1. in single.php, I need featured image only skip photon. not all image. how to modify ‘YOUR_IMAGE_URL’ ?