function uc_product_get_picture in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_product/uc_product.module \uc_product_get_picture()
- 5 uc_product/uc_product.module \uc_product_get_picture()
- 7.3 uc_product/uc_product.module \uc_product_get_picture()
Returns an HTML img tag based on a node's attached image.
Parameters
$node_id: The node's id.
$format: The imagecache preset used to format the image. 'product' by default.
Return value
An HTML img. When $format is not 'product', the image is a link to the 'product_full' preset if a JavaScript display widget is available (Colorbox, Thickbox, and Lightbox2 are possible). For other values of $format, the image links to the node page.
1 call to uc_product_get_picture()
- uc_cart_view_form in uc_cart/
uc_cart.module - Displays a page allowing the customer to view the contents of his or her cart.
File
- uc_product/
uc_product.module, line 1752 - The product module for Ubercart.
Code
function uc_product_get_picture($node_id, $format = 'product') {
$output = '';
$product = node_load($node_id);
if (!module_exists('imagecache') || !($field = variable_get('uc_image_' . $product->type, ''))) {
return '';
}
// Get the current product image widget.
$image_widget = uc_product_get_image_widget();
if (isset($product->{$field})) {
$image = $product->{$field}[0];
$path = $image['filepath'];
if (file_exists($path)) {
$img = theme('imagecache', $format, $path, $image['data']['alt'], $image['data']['title']);
if ($format == 'product') {
if ($image_widget) {
$image_widget_func = $image_widget['callback'];
$output .= '<a title="' . $image['title'] . '" href="' . imagecache_create_url('product_full', $path) . '" ' . $image_widget_func(NULL) . '>';
}
$output .= $img;
if ($image_widget) {
$output .= '</a>';
}
}
else {
$output = l($img, 'node/' . $product->nid, array(
'html' => TRUE,
));
}
}
}
return $output;
}