Skip an Image with Site Accelerator (Formerly Photon)

Explore the benefits of Jetpack

Learn how Jetpack can help you protect, speed up, and grow your WordPress site. Get up to 50% off your first year.

Explore plans

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.

This entry was posted in Code snippets, Tips & Tricks and tagged . Bookmark the permalink.

Jeremy Herve profile
Jeremy Herve

Jetpack Mechanic 🚀 at Automattic. WordPress, board games, TV Series, music.

Explore the benefits of Jetpack

Learn how Jetpack can help you protect, speed up, and grow your WordPress site. Get up to 50% off your first year.

Explore plans

Have a question?

Comments are closed for this article, but we're still here to help! Visit the support forum and we'll be happy to answer any questions.

View support forum
  • Enter your email address to follow this blog and receive news and updates from Jetpack!

    Join 112.8K other subscribers
  • Browse by Topic