首页 WordPress函数大全 image_constrain_size_for_editor()

image_constrain_size_for_editor()

2020-05-02 / 2757阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

image_constrain_size_for_editor( int $width, int $height, string|array $size = 'medium', string $context = null )

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 ‘editor_max_image_size’, that will be called>

参数

$width

(int)
(Required)
Width of the image in pixels.

$height

(int)
(Required)
Height of the image in pixels.

$size

(string|array)
(Optional)
Image size. Accepts any valid image size, or an array of width and height values in pixels (in that order).

Default value: 'medium'

$context

(string)
(Optional)
Could be 'display' (like in a theme) or 'edit' (like inserting into an editor).

Default value: null

返回

(int[]) An array of width and height values.

  • (int) The maximum width in pixels.
  • '1'
    (int) The maximum height in pixels.
大家谈论
    我的见解