_image_get_preview_ratio

Image preview ratio.

Description

(float|int) _image_get_preview_ratio( (int) $w, (int) $h ); 

Internal use only.

Returns (float|int)

Image preview ratio.

Parameters (2)

0. $w (int)
Image width in pixels.
1. $h (int)
Image height in pixels.

Usage

  1. if ( !function_exists( '_image_get_preview_ratio' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/image-edit.php'; 
  3.  
  4. // Image width in pixels. 
  5. $w = -1; 
  6.  
  7. // Image height in pixels. 
  8. $h = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _image_get_preview_ratio($w, $h); 
  12.  

Defined (1)

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

/wp-admin/includes/image-edit.php  
  1. function _image_get_preview_ratio($w, $h) { 
  2. $max = max($w, $h); 
  3. return $max > 400 ? (400 / $max) : 1;