';
$suggestion .= '
';
$suggestion .= '';
/* translators: 1: formatted file size */
$suggestion .= esc_html( sprintf( __( 'Upload JPEG files that are 1000 x 1000 pixels or larger (max. %1$s).', 'woocommerce' ), size_format( wp_max_upload_size() ) ) );
$suggestion .= ' ' . esc_html__( 'How to prepare images?', 'woocommerce' ) . '';
$suggestion .= '
';
$suggestion .= '
';
return $content . $suggestion;
}
/**
* Action to add the filter to add upload tips under the product image thumbnail.
*
* @param WP_Screen $current_screen Current WP_Screen object.
*/
function wc_add_product_post_thumbnail_html_filter( $current_screen ) {
if ( 'product' === $current_screen->post_type && 'post' === $current_screen->base ) {
add_filter( 'admin_post_thumbnail_html', 'wc_product_post_thumbnail_html' );
}
}
add_action( 'current_screen', 'wc_add_product_post_thumbnail_html_filter' );
/**
* Get the placeholder image URL either from media, or use the fallback image.
*
* @param string $size Thumbnail size to use.
* @return string
*/
function wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) {
$src = WC()->plugin_url() . '/assets/images/placeholder.png';
$placeholder_image = get_option( 'woocommerce_placeholder_image', 0 );
if ( ! empty( $placeholder_image ) ) {
if ( is_numeric( $placeholder_image ) ) {
$image = wp_get_attachment_image_src( $placeholder_image, $size );
if ( ! empty( $image[0] ) ) {
$src = $image[0];
}
} else {
$src = $placeholder_image;
}
}
return apply_filters( 'woocommerce_placeholder_img_src', $src );
}
/**
* Get the placeholder image.
*
* Uses wp_get_attachment_image if using an attachment ID @since 3.6.0 to handle responsiveness.
*
* @param string $size Image size.
* @param string|array $attr Optional. Attributes for the image markup. Default empty.
* @return string
*/
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 ) {
$attribute[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
}
$image_html = '