Source file: class.photon.php
View in GitHubParameters
- 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 );
in single.php, I need featured image only skip photon. not all image. how to modify ‘YOUR_IMAGE_URL’ ?
Since the image URL will be different for each post, you won’t be able to use the filter above. Instead, you can follow this method.