当前位置: 首页>>代码示例>>PHP>>正文


PHP wc_placeholder_img函数代码示例

本文整理汇总了PHP中wc_placeholder_img函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_placeholder_img函数的具体用法?PHP wc_placeholder_img怎么用?PHP wc_placeholder_img使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wc_placeholder_img函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sw_product_thumbnail

function sw_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
{
    global $post;
    $html = '';
    $id = get_the_ID();
    $gallery = get_post_meta($id, '_product_image_gallery', true);
    $attachment_image = '';
    if (!empty($gallery)) {
        $gallery = explode(',', $gallery);
        $first_image_id = $gallery[0];
        $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image back'));
    }
    $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '');
    if (has_post_thumbnail()) {
        if ($attachment_image) {
            $html .= '<div class="product-thumb-hover">';
            $html .= get_the_post_thumbnail($post->ID, $size);
            $html .= $attachment_image;
            $html .= '</div>';
        } else {
            $html .= get_the_post_thumbnail($post->ID, $size);
        }
        return $html;
    } elseif (wc_placeholder_img_src()) {
        $html .= wc_placeholder_img($size);
        return $html;
    }
}
开发者ID:pqzada,项目名称:avispate,代码行数:28,代码来源:woocommerce-hook.php

示例2: woocommerce_get_product_thumbnail

 function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $product;
     if ($product->is_type('variable')) {
         global $prdctfltr_global;
         $pf_activated = isset($prdctfltr_global['active_filters']) ? $prdctfltr_global['active_filters'] : array();
         if (!empty($pf_activated)) {
             $attrs = array();
             foreach ($pf_activated as $k => $v) {
                 if (substr($k, 0, 3) == 'pa_') {
                     $attrs = $attrs + array($k => $v[0]);
                 }
             }
             if (count($attrs) > 0) {
                 $curr_var = $product->get_available_variations();
                 foreach ($curr_var as $key => $var) {
                     $curr_var_set[$key]['attributes'] = $var['attributes'];
                     $curr_var_set[$key]['variation_id'] = $var['variation_id'];
                 }
                 $found = WC_Prdctfltr::prdctrfltr_search_array($curr_var_set, $attrs);
             }
         }
     }
     if (isset($found[0]) && $found[0]['variation_id'] && has_post_thumbnail($found[0]['variation_id'])) {
         $image = get_the_post_thumbnail($found[0]['variation_id'], $size);
     } elseif (has_post_thumbnail($product->id)) {
         $image = get_the_post_thumbnail($product->id, $size);
     } elseif (($parent_id = wp_get_post_parent_id($product->id)) && has_post_thumbnail($parent_id)) {
         $image = get_the_post_thumbnail($product, $size);
     } else {
         $image = wc_placeholder_img($size);
     }
     return $image;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:34,代码来源:pf-variable-override.php

示例3: woocommerce_get_product_thumbnail

 function woocommerce_get_product_thumbnail($size = 'news-thumb', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $post;
     if (has_post_thumbnail()) {
         return get_the_post_thumbnail($post->ID, $size, array('class' => 'img-responsive'));
     } elseif (wc_placeholder_img_src()) {
         return wc_placeholder_img($size);
     }
 }
开发者ID:baperrou,项目名称:pedal-bookings,代码行数:9,代码来源:woo-hooks.php

示例4: spyropress_wc_product_thumbnail

function spyropress_wc_product_thumbnail()
{
    $image = '';
    if (has_post_thumbnail()) {
        $image = get_image(array('echo' => false, 'class' => 'img-responsive'));
    } elseif (wc_placeholder_img_src()) {
        $image = wc_placeholder_img('shop_single');
    }
    echo '
    <a href="' . get_permalink() . '">
		<span class="product-thumb-info-image">
			<span class="product-thumb-info-act">
				<span class="product-thumb-info-act-left"><em>' . __('View', 'spyropress') . '</em></span>
				<span class="product-thumb-info-act-right"><em><i class="icon icon-plus"></i> ' . __('Details', 'spyropress') . '</em></span>
			</span>
			' . str_replace('wp-post-image', 'img-responsive', $image) . '
		</span>
	</a>';
}
开发者ID:rinodung,项目名称:myfreetheme,代码行数:19,代码来源:woocommerce-init.php

示例5: get_image

 /**
  * Returns the main product image
  *
  * @param string $size (default: 'shop_thumbnail')
  * @return string
  */
 public function get_image($size = 'shop_thumbnail', $attr = array())
 {
     if (has_post_thumbnail($this->id)) {
         $image = get_the_post_thumbnail($this->id, $size, $attr);
     } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) {
         $image = get_the_post_thumbnail($parent_id, $size, $attr);
     } else {
         $image = wc_placeholder_img($size);
     }
     return $image;
 }
开发者ID:nathanielks,项目名称:woocommerce,代码行数:17,代码来源:abstract-wc-product.php

示例6: woocommerce_get_product_thumbnail

 /**
  * Get the product thumbnail, or the placeholder if not set.
  *
  * @access public
  * @subpackage	Loop
  * @param string $size (default: 'shop_catalog')
  * @param int $placeholder_width (default: 0)
  * @param int $placeholder_height (default: 0)
  * @return string
  */
 function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
 {
     global $post;
     if (has_post_thumbnail()) {
         return get_the_post_thumbnail($post->ID, $size);
     } elseif (wc_placeholder_img_src()) {
         return wc_placeholder_img($size);
     }
 }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:19,代码来源:wc-template-functions.php

示例7: dtwl_product_thumbnail

 function dtwl_product_thumbnail()
 {
     global $post;
     $size = 'shop_thumbnail';
     if (has_post_thumbnail()) {
         echo get_the_post_thumbnail($post->ID, $size, array('class' => "attachment-{$size}"));
     } elseif (wc_placeholder_img_src()) {
         echo wc_placeholder_img($size);
     }
 }
开发者ID:dawnthemes,项目名称:dtwl,代码行数:10,代码来源:dt-template-functions.php

示例8: get_image

 /**
  * Returns the main product image.
  *
  * @param string $size (default: 'shop_thumbnail')
  * @param array $attr
  * @param bool True to return $placeholder if no image is found, or false to return an empty string.
  * @return string
  */
 public function get_image($size = 'shop_thumbnail', $attr = array(), $placeholder = true)
 {
     if (has_post_thumbnail($this->id)) {
         $image = get_the_post_thumbnail($this->id, $size, $attr);
     } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) {
         $image = get_the_post_thumbnail($parent_id, $size, $attr);
     } elseif ($placeholder) {
         $image = wc_placeholder_img($size);
     } else {
         $image = '';
     }
     return str_replace(array('https://', 'http://'), '//', $image);
 }
开发者ID:nishitlangaliya,项目名称:woocommerce,代码行数:21,代码来源:abstract-wc-product.php

示例9: woocommerce_get_product_thumbnail

function woocommerce_get_product_thumbnail($size = 'product_small_thumbnail', $placeholder_width = 0, $placeholder_height = 0)
{
    global $post;
    if (has_post_thumbnail()) {
        $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'shop_catalog');
        return get_the_post_thumbnail($post->ID, $size, array('data-src' => $image_src[0], 'class' => 'lazyOwl'));
    } elseif (wc_placeholder_img_src()) {
        return wc_placeholder_img($size);
    }
}
开发者ID:quyendam2612,项目名称:quanao,代码行数:10,代码来源:functions.php

示例10: test_wc_placeholder_img

 /**
  * Test wc_placeholder_img()
  *
  * @since 2.4
  */
 public function test_wc_placeholder_img()
 {
     $sizes = array('shop_thumbnail' => array('width' => '180', 'height' => '180'), 'shop_single' => array('width' => '600', 'height' => '600'), 'shop_catalog' => array('width' => '300', 'height' => '300'));
     foreach ($sizes as $size => $values) {
         $img = '<img src="' . wc_placeholder_img_src() . '" alt="' . __('Placeholder', 'woocommerce') . '" width="' . $values['width'] . '" class="woocommerce-placeholder wp-post-image" height="' . $values['height'] . '" />';
         $this->assertEquals(apply_filters('woocommerce_placeholder_img', $img), wc_placeholder_img($size));
     }
     $img = '<img src="' . wc_placeholder_img_src() . '" alt="' . __('Placeholder', 'woocommerce') . '" width="180" class="woocommerce-placeholder wp-post-image" height="180" />';
     $this->assertEquals(apply_filters('woocommerce_placeholder_img', $img), wc_placeholder_img());
 }
开发者ID:nightbook,项目名称:woocommerce,代码行数:15,代码来源:functions.php

示例11: woocommerce_get_product_thumbnail

 /**
  * Get the product thumbnail, or the placeholder if not set.
  *
  * @subpackage	Loop
  * @param string $size (default: 'shop_catalog')
  * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0)
  * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0)
  * @return string
  */
 function woocommerce_get_product_thumbnail($size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0)
 {
     global $post;
     if (has_post_thumbnail() && wp_attachment_is_image(get_post_thumbnail_id())) {
         return get_the_post_thumbnail($post->ID, $size);
     } elseif (wc_placeholder_img_src()) {
         return wc_placeholder_img($size);
     }
 }
开发者ID:rsantellan,项目名称:wordpress-ecommerce,代码行数:18,代码来源:wc-template-functions.php

示例12: woocommerce_get_product_thumbnail

function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
{
    global $post;
    if (has_post_thumbnail()) {
        return "<div class=\"imageswrap productthumbnail\"><div class=\"imageHOpacity\"></div>" . get_the_post_thumbnail($post->ID, $size) . "</div>";
    } elseif (wc_placeholder_img_src()) {
        return wc_placeholder_img($size);
    }
}
开发者ID:rmilano24,项目名称:moto,代码行数:9,代码来源:utilities.php

示例13: woocommerce_template_loop_product_thumbnail

 function woocommerce_template_loop_product_thumbnail($view = 'grid-view')
 {
     global $woocommerce_loop, $post, $media_center_theme_options, $woocommerce_loop;
     $product_item_size = isset($woocommerce_loop['product_item_size']) ? $woocommerce_loop['product_item_size'] : $media_center_theme_options['product_item_size'];
     switch ($product_item_size) {
         case 'size-medium':
             $image_size = 'product-medium';
             break;
         case 'size-small':
             $image_size = 'product-small';
             break;
         case 'size-big':
             $image_size = 'product-large';
             break;
         default:
             $image_size = 'product-medium';
     }
     if ($view == 'list-view') {
         $image_size = 'product-medium';
     }
     echo '<div class="product-image">';
     echo '<a href="' . get_permalink($post->ID) . '">';
     if ($media_center_theme_options['lazy_loading']) {
         if (has_post_thumbnail($post->ID)) {
             $post_thumbnail_ID = get_post_thumbnail_id($post->ID);
             $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_ID, $image_size);
         } else {
             $dimensions = wc_get_image_size($image_size);
             $post_thumbnail_src = array(wc_placeholder_img_src(), esc_attr($dimensions['width']), esc_attr($dimensions['height']));
         }
         echo '<img class="post-image echo-lazy-loading" src="' . get_template_directory_uri() . '/assets/images/blank.gif" alt="" data-echo="' . $post_thumbnail_src[0] . '" width="' . $post_thumbnail_src[1] . '" height="' . $post_thumbnail_src[2] . '">';
     } else {
         if (has_post_thumbnail($post->ID)) {
             echo get_the_post_thumbnail($post->ID, $image_size);
         } else {
             echo wc_placeholder_img($image_size);
         }
     }
     echo '</a>';
     echo '</div>';
 }
开发者ID:Qualitair,项目名称:ecommerce,代码行数:41,代码来源:woocommerce-template-functions.php

示例14: do_action

    ?>
>
<?php 
}
?>

<?php 
do_action('woocommerce_before_shop_loop_item');
?>
	<?php 
$image_html = "";
if (has_post_thumbnail()) {
    $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog');
} else {
    if (wc_placeholder_img_src()) {
        $image_html = wc_placeholder_img('shop_catalog');
    }
}
?>
	<?php 
if ($shop_product_listing == 'style1') {
    ?>
		<figure class="fresco">
			<?php 
    do_action('thb_product_badge');
    ?>
			<?php 
    echo $image_html;
    ?>
			
			<div class="overlay"></div>
开发者ID:developmentDM2,项目名称:CZND,代码行数:31,代码来源:content-product.php

示例15: content

 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('per_page' => '', 'orderby' => 'name', 'order' => 'ASC', 'ids' => '', 'hide_empty' => 'true', 'parent' => '', 'autoheight' => true, 'autoplay' => false, 'mousedrag' => true, 'autoplayspeed' => 5000, 'slidespeed' => 200, 'carousel_skin' => '', 'desktop' => 4, 'desktopsmall' => 3, 'tablet' => 2, 'mobile' => 1, 'gutters' => true, 'navigation' => true, 'navigation_always_on' => true, 'navigation_position' => 'center-outside', 'navigation_style' => 'normal', 'pagination' => false, 'pagination_position' => 'center-bottom', 'pagination_style' => 'dot-stroke', 'css_animation' => '', 'animation_delay' => '', 'el_class' => '', 'css' => ''), $atts);
     $atts['columns'] = $atts['desktop'];
     $atts['number'] = $atts['per_page'];
     $atts['hide_empty'] = apply_filters('sanitize_boolean', $atts['hide_empty']);
     extract($atts);
     $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'products-brands-carousel ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'woocommerce' => 'woocommerce columns-' . $desktop, 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' '));
     $carousel_ouput = cruxstore_render_carousel(apply_filters('cruxstore_render_args', $atts), '', 'cruxstore-owl-carousel');
     $output = $carousel_html = '';
     if (isset($atts['ids'])) {
         $ids = explode(',', $atts['ids']);
         $ids = array_map('trim', $ids);
     } else {
         $ids = array();
     }
     $hide_empty = $atts['hide_empty'] == true || $atts['hide_empty'] == 1 ? 1 : 0;
     // get terms and workaround WP bug with parents/pad counts
     $args = array('orderby' => $atts['orderby'], 'order' => $atts['order'], 'hide_empty' => $hide_empty, 'include' => $ids, 'pad_counts' => true, 'child_of' => $atts['parent']);
     $product_brands = get_terms('yith_product_brand', $args);
     if ('' !== $atts['parent']) {
         $product_brands = wp_list_filter($product_brands, array('parent' => $atts['parent']));
     }
     if ($hide_empty) {
         foreach ($product_brands as $key => $brand) {
             if ($brand->count == 0) {
                 unset($product_brands[$key]);
             }
         }
     }
     if ($atts['number']) {
         $product_brands = array_slice($product_brands, 0, $atts['number']);
     }
     ob_start();
     if ($product_brands) {
         global $woocommerce_carousel;
         $woocommerce_carousel = 'normal';
         $css_animation = cruxstore_getCSSAnimation($css_animation);
         foreach ($product_brands as $key => $term) {
             if ($animation_delay) {
                 $animation_delay_item = sprintf(' data-wow-delay="%sms"', $key * $animation_delay);
             } else {
                 $animation_delay_item = '';
             }
             echo '<div class="brand-banner' . $css_animation . '"' . $animation_delay_item . '><div class="brand-banner-content">';
             $thumbnail_id = absint(yith_wcbr_get_term_meta($term->term_id, 'thumbnail_id', true));
             $image_size = apply_filters('cruxstore_brand_logo', 'cruxstore_grid');
             if ($thumbnail_id) {
                 $image = wp_get_attachment_image_src($thumbnail_id, $image_size);
                 printf('<div class="brand-image"><img src="%s" width="%d" height="%d" alt="%s"/></div>', $image[0], $image[1], $image[2], $term->name);
             } else {
                 do_action('yith_wcbr_no_brand_logo', $term->term_id, $term, 'yith_wcbr_logo_size', false, false);
                 echo '<div class="brand-image">' . wc_placeholder_img() . '</div>';
             }
             printf('<h4 class="brand-count"><span>%s</span> %s</a></h4>', $term->count, esc_html__('Products', 'cruxstore'));
             printf('<a href="%s">%s</a>', get_term_link($term), $term->name);
             echo '</div></div>';
         }
     }
     wp_reset_postdata();
     $carousel_html .= ob_get_clean();
     if ($carousel_html) {
         $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass));
         $output = '<div class="' . esc_attr($elementClass) . '"><div class="products-brands-inner">' . str_replace('%carousel_html%', $carousel_html, $carousel_ouput) . '</div></div>';
     }
     return $output;
 }
开发者ID:websideas,项目名称:Mondova,代码行数:67,代码来源:brands.php


注:本文中的wc_placeholder_img函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。