wc_get_image_size

Get an image size.

Description

(array) wc_get_image_size( (mixed) $image_size ); 

Variable is filtered by woocommerce_get_image_size_.

Returns (array)

Parameters (1)

0. $image_size (mixed)
The image size.

Usage

  1. if ( !function_exists( 'wc_get_image_size' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // The image size. 
  5. $image_size = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_image_size($image_size); 
  9.  

Defined (1)

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

/includes/wc-core-functions.php  
  1. function wc_get_image_size( $image_size ) { 
  2. if ( is_array( $image_size ) ) { 
  3. $width = isset( $image_size[0] ) ? $image_size[0] : '300'; 
  4. $height = isset( $image_size[1] ) ? $image_size[1] : '300'; 
  5. $crop = isset( $image_size[2] ) ? $image_size[2] : 1; 
  6.  
  7. $size = array( 
  8. 'width' => $width,  
  9. 'height' => $height,  
  10. 'crop' => $crop,  
  11. ); 
  12.  
  13. $image_size = $width . '_' . $height; 
  14.  
  15. } elseif ( in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ) ) { 
  16. $size = get_option( $image_size . '_image_size', array() ); 
  17. $size['width'] = isset( $size['width'] ) ? $size['width'] : '300'; 
  18. $size['height'] = isset( $size['height'] ) ? $size['height'] : '300'; 
  19. $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; 
  20.  
  21. } else { 
  22. $size = array( 
  23. 'width' => '300',  
  24. 'height' => '300',  
  25. 'crop' => 1,  
  26. ); 
  27.  
  28. return apply_filters( 'woocommerce_get_image_size_' . $image_size, $size );