Skip an Image with Site Accelerator (Formerly Photon)

Once you activate the Site Accelerator module, it will automatically cache and serve all images you’ve added to your posts and pages that have been uploaded to your site.

You can exclude a specific image or an entire page from Site Accelerator easily.

To exclude an entire post or page from using Site Accelerator, 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, Site Accelerator 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 Site Accelerator, 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 );

If you’d like to disable Site Accelerator in other specific situations instead, you can check this tutorial.

Découvrez les avantages de Jetpack

Découvrez comment Jetpack peut vous aider à protéger, accélérer et développer votre site WordPress.

Découvrir les offres

Une question ?

Les commentaires sont fermés pour cet article, mais nous sommes toujours là pour vous aider ! Consultez le forum d’assistance et nous répondrons volontiers à toutes vos questions.

Voir le forum d’assistance