Lightbox issue, need a bit of help
Posted: Wed Oct 19, 2011 10:40 am
I've got a website which is using lightbox.
It works fine in most aspects but I need to get it working within a function.
Basically I'm using wp-ecommerce as part of wordpress and using its goldcart to have a gallery. I don't get much reponse from their forums at all.
The code for the lightbox is simple, just a 'lightbox' rel to the link. Easy. However when I try adding it into this function it just doesn't seem to work.
Wondering if anyone can help with it:
If anyone has any ideas I'd really appreciate this.
Regards,
Aravona
It works fine in most aspects but I need to get it working within a function.
Basically I'm using wp-ecommerce as part of wordpress and using its goldcart to have a gallery. I don't get much reponse from their forums at all.
The code for the lightbox is simple, just a 'lightbox' rel to the link. Easy. However when I try adding it into this function it just doesn't seem to work.
Wondering if anyone can help with it:
Code: Select all
function gold_shpcrt_display_gallery_cue($product_id, $invisible = false) {
global $wpdb;
$output ='';
$siteurl = get_option('siteurl');
/* No GD? No gallery. No gallery option? No gallery. Range variable set? Apparently, no gallery. */
if ( get_option( 'show_gallery' ) == 1 && ! isset( $_GET['range'] ) && function_exists( "getimagesize" ) ) {
if ( version_compare( WPSC_VERSION, '3.8', '<' ) ) {
/* get data about the base product image */
$product = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$product_id."' LIMIT 1",ARRAY_A);
$image_link = WPSC_IMAGE_URL.$product['image']."";
$image_file_name = $product['image'];
$imagepath = WPSC_THUMBNAIL_DIR.$image_file_name;
$base_image_size = @getimagesize($imagepath);
/* get data about the extra product images */
$images = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` = '$product_id' AND `id` NOT IN('$image_file_name') ORDER BY `image_order` ASC",ARRAY_A);
$output = "";
$new_height = get_option('wpsc_gallery_image_height');
$new_width = get_option('wpsc_gallery_image_width');
if(count($images) > 0) {
/* display gallery */
if($invisible == true) {
foreach($images as $image) {
$extra_imagepath = WPSC_IMAGE_DIR.$image['image']."";
$extra_image_size = @getimagesize($extra_imagepath);
$thickbox_link = WPSC_IMAGE_URL.$image['image']."";
$image_link = "index.php?image_id=".$image['id']."&width=".$new_width."&height=".$new_height."";
$output .= "<a href='".$thickbox_link."'> </a>";
}
} else {
$output .= "<h2 class='prodtitles'>".__("Gallery")."</h2>";
$output .= "<div class='wpcart_gallery_cues'>";
if($images != null) {
foreach($images as $image) {
$extra_imagepath = WPSC_IMAGE_DIR.$image['image']."";
$extra_image_size = @getimagesize($extra_imagepath);
$thickbox_link = WPSC_IMAGE_URL.$image['image']."";
$image_link = "index.php?image_id=".$image['id']."&width=".$new_width."&height=".$new_height."";
$output .= "<a href='".$thickbox_link."' rel='lightbox'><img src='$image_link' alt='$product_name' title='$product_name' /></a>";
}
}
$output .= "</div>";
}
}
} else {
$output = '';
$product_name = get_the_title( $product_id );
$output .= "<div class='wpcart_gallery_cue'>";
$args = array(
'post_type' => 'attachment',
'post_parent' => $product_id,
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => -1
);
$attachments = get_posts($args);
$featured_img = get_post_meta($product_id, '_thumbnail_id');
$thumbnails = array();
if (count($attachments) > 1) {
foreach ($attachments as $post) {
setup_postdata($post);
$link = wp_get_attachment_link( $post->ID, 'gold-thumbnails' );
$size = is_single() ? 'medium-single-product' : 'product-thumbnails';
$preview_link = wp_get_attachment_image_src( $post->ID, $size);
$link = str_replace( 'a href' , 'a rel="lightbox" href' , $link );
// always display the featured thumbnail first
if ( in_array( $post->ID, $featured_img ) )
array_unshift( $thumbnails, $link );
else
$thumbnails[] = $link;
}
}
$output .= implode( "\n", $thumbnails );
$output .= "</div>";
wp_reset_query();
} //closes if > 3.8 condition
} //closes if gallery setting condition
return $output;
}Regards,
Aravona