Skip navigation
Help

theme_uc_product_image

6 uc_product.module theme_uc_product_image($images, $teaser = 0, $page = 0)
7 uc_product.theme.inc theme_uc_product_image($variables)

Formats a product's images.

Parameters

$variables:

  • images: An array of image render elements, each containing:

    • uri: URI of image.
    • alt: Alternate text to display for image.
    • title: Title for image.

See also

theme_image_style()

Related topics

File

ubercart/uc_product/uc_product.theme.inc, line 172
Theme functions for uc_product module.

Code

function theme_uc_product_image($variables) {
  static $rel_count = 0;
  $images = $variables['images'];

  // Get the current product image widget.
  $image_widget = uc_product_get_image_widget();

  $first = array_shift($images);

  $output = '<div class="product-image"><div class="main-product-image">';
  $output .= '<a href="' . image_style_url('uc_product_full', $first['uri']) . '" title="' . $first['title'] . '"';
  if ($image_widget) {
    $image_widget_func = $image_widget['callback'];
    $output .= $image_widget_func($rel_count);
  }
  $output .= '>';
  $output .= theme('image_style', array(
    'style_name' => 'uc_product', 
    'path' => $first['uri'], 
    'alt' => $first['alt'], 
    'title' => $first['title'],
  ));
  $output .= '</a></div>';

  if (!empty($images)) {
    $output .= '<div class="more-product-images">';
    foreach ($images as $thumbnail) {
      // Node preview adds extra values to $images that aren't files.
      if (!is_array($thumbnail) || empty($thumbnail['uri'])) {
        continue;
      }
      $output .= '<a href="' . image_style_url('uc_product_full', $thumbnail['uri']) . '" title="' . $thumbnail['title'] . '"';
      if ($image_widget) {
        $output .= $image_widget_func($rel_count);
      }
      $output .= '>';
      $output .= theme('image_style', array(
        'style_name' => 'uc_thumbnail', 
        'path' => $thumbnail['uri'], 
        'alt' => $thumbnail['alt'], 
        'title' => $thumbnail['title'],
      ));
      $output .= '</a>';
    }
    $output .= '</div>';
  }

  $output .= '</div>';
  $rel_count++;

  return $output;
}