Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Created February 5, 2015 11:01
Show Gist options
  • Save JudeRosario/b9cb606556f708ad68ff to your computer and use it in GitHub Desktop.
Save JudeRosario/b9cb606556f708ad68ff to your computer and use it in GitHub Desktop.
MarketPress Lightbox Fix
// Some themes cause issues with the product list MarketPress displays, especially the Lightboxes
add_filter('mp_product_image','fix_lightbox',10,4);
function fix_lightbox( $image, $context, $post_id, $size ) {
// Apply this fix only when its a product list
if ($context === 'list') :
$thumb_html = get_the_post_thumbnail($post_id, $size);
// Simple Regex that sets link attribute correctly
$matches = array();
if (preg_match('/src=\".*?\"/', $thumb_html, $matches)) {
$link = preg_replace("/src=/", "href=", $matches[0]);
$image = preg_replace('/href=\".*?\"/', $link, $image);
}
endif;
return $image ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment