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.
  • (array) First item is the width, the second item is the height.
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_get_audio_extensions, wp_count_comments, wp_count_sites

Top Google Results

User discussions

wpseek mobile