Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jetpack breaks images on MetaSlider, and this disabled JetPack from doing so.
add_filter('jetpack_photon_skip_image', 'metaslider_remove_jetpack', 10, 2);
add_filter('jetpack_lazy_images_skip_image_with_attributes', 'metaslider_remove_jetpack', 10, 2);
function metaslider_remove_jetpack($val, $src) {
// The lazy load filter send the src as a param
$src = isset($src['src']) ? $src['src'] : $src;
// Get an array of slideshow images
$slide_image_names = array_map(function ($post) {
$image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
// Extract the filename only from the slide image as WP will add sizes
return pathinfo(end(explode('/', $image)))['filename'];
}, get_posts(['post_type' => 'ml-slide', 'posts_per_page' => -1]));
// Filter through every slide image and see if Jetpack is trying to serve it
$skip = array_filter($slide_image_names, function ($slide_src) use ($src) {
return strpos($src, $slide_src) !== false;
return count($skip) ? true : $val;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment