image_constrain_size_for_editor


image_constrain_size_for_editor ( $width, $height, $size = 'medium', $context = null )

Parameters:
  • (int) width Width of the image in pixels.
  • (int) height Height of the image in pixels.
  • (string|array) size Optional. Image size. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'medium'.
  • (string) context Optional. Could be 'display' (like in a theme) or 'edit' (like inserting into an editor). Default null.
Returns:
  • (int[]) { An array of width and height values. @type int $0 The maximum width in pixels. @type int $1 The maximum height in pixels. }
Defined at:

Description

Scale down the default size of an image.This is so that the image is a better fit for the editor and theme. The `$size` parameter accepts either an array or a string. The supported string values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at 128 width and 96 height in pixels. Also supported for the string value is 'medium', 'medium_large' and 'full'. The 'full' isn't actually supported, but any value other than the supported will result in the content_width size or 500 if that is not set. Finally, there is a filter named Array, that will be called on the calculated array for width and height, respectively.

Related Functions

image_media_send_to_editor, get_image_send_to_editor, media_send_to_editor, format_for_editor, image_resize_dimensions

Top Google Results

User discussions

wpseek mobile