wp_embed_defaults()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_embed_defaults( string $url = '' ): int[]
Описание
По умолчанию ширина равна ширине содержимого, заданной темой. Если тема не задаёт ширину содержимого, используется 500px.
Высота по умолчанию в 1,5 раза больше ширины или 1000px, в зависимости от того, что меньше.
Фильтр 'embed_defaults' можно использовать для изменения любого из этих значений.
Оригинал (английский)
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 ’embed_defaults’ filter can be used to adjust either of these values.
Параметры
$url
string
необязательный
= ''
Возвращаемое значение
int[]
Исходный код
wp-includes/embed.php:67
function wp_embed_defaults( $url = '' ) {
if ( ! empty( $GLOBALS['content_width'] ) ) {
$width = (int) $GLOBALS['content_width'];
}
if ( empty( $width ) ) {
$width = 500;
}
$height = min( (int) 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 );
}
История изменений
| Версия | Описание |
|---|---|
| 2.9.0 | Introduced. |

