wc_placeholder_img()
Get the placeholder image.
Uses wp_get_attachment_image if using an attachment ID @since 3.6.0 to handle responsiveness.
Хуки из функции
Возвращает
Строку
.
Использование
wc_placeholder_img( $size, $attr );
- $size(строка)
- Image size.
По умолчанию: 'woocommerce_thumbnail' - $attr(строка|массив)
- Attributes for the image markup.
По умолчанию: ''
Код wc_placeholder_img() wc placeholder img WC 8.7.0
function wc_placeholder_img( $size = 'woocommerce_thumbnail', $attr = '' ) { $dimensions = wc_get_image_size( $size ); $placeholder_image = get_option( 'woocommerce_placeholder_image', 0 ); $default_attr = array( 'class' => 'woocommerce-placeholder wp-post-image', 'alt' => __( 'Placeholder', 'woocommerce' ), ); $attr = wp_parse_args( $attr, $default_attr ); if ( wp_attachment_is_image( $placeholder_image ) ) { $image_html = wp_get_attachment_image( $placeholder_image, $size, false, $attr ); } else { $image = wc_placeholder_img_src( $size ); $hwstring = image_hwstring( $dimensions['width'], $dimensions['height'] ); $attributes = array(); foreach ( $attr as $name => $value ) { $attributes[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"'; } $image_html = '<img src="' . esc_url( $image ) . '" ' . $hwstring . implode( ' ', $attributes ) . '/>'; } return apply_filters( 'woocommerce_placeholder_img', $image_html, $size, $dimensions ); }