wp_constrain_dimensions ( $current_width, $current_height, $max_width = 0, $max_height = 0 )

  • (int) current_width Current width of the image.
  • (int) current_height Current height of the image.
  • (int) max_width Optional. Max width in pixels to constrain to. Default 0.
  • (int) max_height Optional. Max height in pixels to constrain to. Default 0.
  • (int[]) { An array of width and height values. @type int $0 The width in pixels. @type int $1 The height in pixels. }
Defined at:


Calculates the new dimensions for a down-sampled image.If either width or height are empty, no constraint is applied on that dimension.

Related Functions

wp_shrink_dimensions, wp_expand_dimensions, wp_register_dimensions_support, wp_get_audio_extensions, wp_image_src_get_dimensions

Top Google Results

User discussions

wpseek mobile