wp_embed_defaults
函数
wp_embed_defaults ( $url = '' )
- 参数
-
-
(string)
$url
Optional. The URL that should be embedded. Default empty.- Required: 否
- Default: (empty)
-
(string)
- 返回值
-
- (int[]) { Indexed array of the embed width and height in pixels. @type int $0 The embed width. @type int $1 The embed height. }
- 定义位置
-
-
wp-includes/embed.php
, line 67
-
wp-includes/embed.php
- 引入
- 2.9.0
- 弃用
- –
Creates default array of embed parameters.
The width defaults to the content width as specified by the theme. If the
theme does not specify a content width, then 500px is used.
The default height is 1.5 times the width, or 1000px, whichever is smaller.
The {@see ’embed_defaults’} filter can be used to adjust either of these values.
function wp_embed_defaults( $url = '' ) {
if ( ! empty( $GLOBALS['content_width'] ) ) {
$width = (int) $GLOBALS['content_width'];
}
if ( empty( $width ) ) {
$width = 500;
}
$height = min( ceil( $width * 1.5 ), 1000 );
/**
* Filters the default array of embed dimensions.
*
* @since 2.9.0
*
* @param int[] $size {
* Indexed array of the embed width and height in pixels.
*
* @type int $0 The embed width.
* @type int $1 The embed height.
* }
* @param string $url The URL that should be embedded.
*/
return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


