Reply To: Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more)

Not one for queueing up? Get faster support with AdRotate Pro!
The forum is checked a few times per week. With AdRotate Pro you can get answers faster using email support.
More private, more direct and usually a solution within a day! Learn more »

Home Forums AdRotate for WordPress General Support Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more) Reply To: Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more)

#39649

KZeni
Badges:

Oh, and here’s the code I added to my theme’s functions.php file to make use of that new filter so all images used by AdRotate are automatically passed through the WP.com CDN via Jetpack’s Photon feature (when available).


// Send images in AdRotate through Jetpack's Photon CDN service
function adrotate_apply_jetpack_photon($image){
	if(function_exists('jetpack_photon_url')){
		return jetpack_photon_url($image);
	}else{
		return $image;
	}
}
add_filter('adrotate_image_src','adrotate_apply_jetpack_photon');

This would otherwise not be possible without this filter being added. Keep in mind that this will stop working if AdRotate is updated without including this new feature (as it will overwrite the patch adding the new filter).