wp_constrain_dimensions


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

Parameters:
  • (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.
Returns:
  • (array) First item is the width, the second item is the height.
Defined at:

Description

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_get_post_revisions

Top Google Results

User discussions

wpseek mobile