woocommerce_placeholder_img

The WooCommerce woocommerce placeholder img hook.

Description

Parameters (3)

0. $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height — Optional. (string) => '' . esc_attr__( 'Placeholder', 'woocommerce' ) . ''
The img src wc placeholder img src alt esc attr placeholder woocommerce width esc attr dimensions width class woocommerce placeholder wp post image height esc attr dimensions height.
1. $size (unknown)
The size.
2. $dimensions (unknown)
The dimensions.

Usage

To run the hook, copy the example below.
  1. $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height = apply_filters( 'woocommerce_placeholder_img', $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height, $size, $dimensions ); 
  2.  
  3. if ( !empty( $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_placeholder_img callback 
  2. function filter_woocommerce_placeholder_img( $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height, $size, $dimensions ) { 
  3. // make filter magic happen here... 
  4. return $img_src_wc_placeholder_img_src_alt_esc_attr_placeholder_woocommerce_width_esc_attr_dimensions_width_class_woocommerce_placeholder_wp_post_image_height_esc_attr_dimensions_height
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'woocommerce_placeholder_img', 'filter_woocommerce_placeholder_img', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'woocommerce_placeholder_img', 'filter_woocommerce_placeholder_img', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/wc-product-functions.php  
  1. return apply_filters( 'woocommerce_placeholder_img', '<img src="' . wc_placeholder_img_src() . '" alt="' . esc_attr__( 'Placeholder', 'woocommerce' ) . '" width="' . esc_attr( $dimensions['width'] ) . '" class="woocommerce-placeholder wp-post-image" height="' . esc_attr( $dimensions['height'] ) . '" />', $size, $dimensions );