Disable Jetpack’s Photon module for certain Image

598
jetpack-photon

Once you activate the Photon 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 Photon easily.

Method-1

Html Code Before

<img class=”aligncenter size-full wp-image-11026″ src=”https://wordzz.com/wp-content/uploads/2017/04/jetpack-photon.jpg&#8221; alt=”jetpack-photon” width=”1080″ height=”650″ />

Html Code After

<img class=”aligncenter size-full wp-image-11026” src=”../wp-content/uploads/2017/04/jetpack-photon.jpg” alt=”jetpack-photon” width=”1080″ height=”650″ />

Method-2

Occasionally, users would like to disable Photon for certain requests, such as when a plugin or theme calls one of WordPress’s image functions (wp_get_attachment_image(), wp_get_attachment_image_src(), or anything else that ultimately calls image_downsize()).
Disable Jetpack’s Photon module for certain calls to WordPress image functions
<?php
$photon_removed = remove_filter( ‘image_downsize’, array( Jetpack_Photon::instance(), ‘filter_image_downsize’ ) );
// Call wp_get_attachment_image(), wp_get_attachment_image_src(), or anything else that ultimately calls image_downsize()
if ( $photon_removed ) {
add_filter( ‘image_downsize’, array( Jetpack_Photon::instance(), ‘filter_image_downsize’ ), 10, 3 );
}
Facebook Comments