/** * Output a dummy thumbnail image in case the current product in the loop does not have a specified * featured thumbnail. * * @since 4.0 * @uses $_wp_additional_image_size The array containing registered image sizes * @uses apply_filters() Applies 'wpsc_product_no_thumbnail_url' filter * @uses apply_filters() Applies 'wpsc_product_no_thumbnail_html' filter * * @param string $size Optional. If this is not specified, the appropriate size will be detected based on the current page being viewed. See {@link wpsc_get_product_thumbnail()} for a list of available sizes you can use. * @param string $attr Optional. Query string or array of attributes. Defaults to ''. */ function wpsc_product_no_thumbnail_image($size = false, $attr = '') { global $_wp_additional_image_sizes; // automatically detect the correct $size if it's not specified if (!$size) { if (is_singular('wpsc-product')) { $size = 'single'; } elseif (is_tax('wpsc_product_category') || is_tax('product_tag')) { $size = 'taxonomy'; } elseif (wpsc_is_cart() || wpsc_is_customer_account() || wpsc_is_checkout()) { $size = 'cart'; } else { $size = 'archive'; } } if (is_string($size)) { $wp_size = $size; if (in_array($size, array('single', 'taxonomy', 'cart', 'archive'))) { $wp_size = 'wpsc_product_' . $size . '_thumbnail'; } if (array_key_exists($wp_size, $_wp_additional_image_sizes)) { $dimensions = $_wp_additional_image_sizes[$wp_size]; } else { $dimensions = array('width' => '', 'height' => ''); } } elseif (is_array($size) && count($size) == 2) { $dimensions = array('width' => $size[0], 'height' => $size[1]); } else { return; } $title = wpsc_product_title_attribute(array('echo' => false)); $src = apply_filters('wpsc_product_no_thumbnail_url', wpsc_locate_asset_uri('images/noimage.png'), $size, $attr); $html = '<img alt="' . $title . '" src="' . $src . '" title="' . $title . '" width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" />'; $html = apply_filters('wpsc_product_no_thumbnail_html', $html, $size, $attr); echo $html; }
<div class="wpsc-product-meta"> <?php wpsc_edit_product_link(); ?> </div><!-- .entry-meta --> </div><!-- .wpsc-product-summary --> <div class="wpsc-thumbnail-wrapper"> <a class="wpsc-thumbnail wpsc-product-thumbnail" href="<?php wpsc_product_permalink(); ?> " title="<?php wpsc_product_title_attribute(); ?> " > <?php if (wpsc_has_product_thumbnail()) { ?> <?php wpsc_product_thumbnail(); ?> <?php } else { ?> <?php wpsc_product_no_thumbnail_image(); ?>