Enqueue visual composer prettyPhoto for custom posts.
// PHP in functions.php
function products_scripts() {
if(is_singular('product')) {
wp_enqueue_style( 'prettyPhoto_cs', '/wp-content/plugins/js_composer/assets/lib/prettyphoto/css/prettyPhoto.min.css' );
wp_enqueue_script( 'prettyPhoto_js', '/wp-content/plugins/js_composer/assets/lib/prettyphoto/js/jquery.prettyPhoto.min.js', array('jquery'), '', true);
}
}
add_action( 'wp_enqueue_scripts', 'products_scripts' );
// PHP on page/post template
<?php foreach( $images as $image ): ?>
<a href="<?php echo $image['url']; ?>" class="prettyphoto" rel="prettyPhoto[galleryName]">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<?php endforeach; ?>
// JavaScript on page/post template
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function(){
jQuery("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>