Created
February 5, 2015 11:01
-
-
Save JudeRosario/b9cb606556f708ad68ff to your computer and use it in GitHub Desktop.
MarketPress Lightbox Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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