function uc_product_get_picture in Ubercart 5
Same name and namespace in other branches
- 8.4 uc_product/uc_product.module \uc_product_get_picture()
- 6.2 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: By default, 'uc_thumbnail', with possible values of '_original', 'thumbnail', and 'preview'.
Return value
An HTML img. When $format is 'uc_thumbnail', the image is a link to the node. When $format is 'preview', the image is a link to the image file.
1 call to uc_product_get_picture()
- uc_cart_view_form in uc_cart/
uc_cart.module - Display a page allowing the customer to view the contents of his or her cart.
File
- uc_product/
uc_product.module, line 2532 - The product module for Ubercart.
Code
function uc_product_get_picture($node_id, $format = 'product') {
$img = '';
$product = node_load($node_id);
if (!module_exists('imagecache')) {
return '';
}
$path = $product->field_image_cache[0]['filepath'];
if (file_exists($path)) {
$img = theme('imagecache', $format, $path, $product->field_image_cache[0]['alt'], $product->field_image_cache[0]['title']);
if ($format == 'product') {
$img = '<a href="' . check_url(file_create_url($path)) . '" class="thickbox" rel="field_image_cache">' . $img . '</a>';
}
else {
$img = l($img, 'node/' . $product->nid, array(), null, null, false, true);
}
}
return $img;
}