wp_embed_defaults

The timeline below displays how wordpress function wp_embed_defaults has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 * @return int[] {
 *     Indexed array of the embed width and height in pixels.
 *
 *     @type int $0 The embed width.
 *     @type int $1 The embed height.
 * }
 */
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);
}

WordPress Version: 5.9

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 * @return int[] {
 *     Indexed array of the embed width and height in pixels.
 *
 *     @type int $0 The embed width.
 *     @type int $1 The embed height.
 * }
 */
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);
}

WordPress Version: 5.7

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 * @return array {
 *     Indexed array of the embed width and height in pixels.
 *
 *     @type int $0 The embed width.
 *     @type int $1 The embed height.
 * }
 */
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);
}

WordPress Version: 5.5

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 * @return array {
 *     Indexed array of the embed width and height in pixels.
 *
 *     @type int $0 The embed width.
 *     @type int $1 The embed height.
 * }
 */
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 array  $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);
}

WordPress Version: 5.4

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 *
 * @return array {
 *     Indexed array of the embed width and height in pixels.
 *
 *     @type int $0 The embed width.
 *     @type int $1 The embed height.
 * }
 */
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 array  $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);
}

WordPress Version: 4.6

/**
 * 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.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 *
 * @return array Default embed parameters.
 */
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 array  $size An array of embed width and height values
     *                     in pixels (in that order).
     * @param string $url  The URL that should be embedded.
     */
    return apply_filters('embed_defaults', compact('width', 'height'), $url);
}

WordPress Version: 4.4

/**
 * 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 'embed_defaults' filter can be used to adjust either of these values.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 *
 * @return array Default embed parameters.
 */
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);
    /**
     * Filter the default array of embed dimensions.
     *
     * @since 2.9.0
     *
     * @param array  $size An array of embed width and height values
     *                     in pixels (in that order).
     * @param string $url  The URL that should be embedded.
     */
    return apply_filters('embed_defaults', compact('width', 'height'), $url);
}

WordPress Version: 4.3

/**
 * Create 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 'embed_defaults' filter can be used to adjust either of these values.
 *
 * @since 2.9.0
 *
 * @global int $content_width
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 *
 * @return array Default embed parameters.
 */
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);
    /**
     * Filter the default array of embed dimensions.
     *
     * @since 2.9.0
     *
     * @param int    $width  Width of the embed in pixels.
     * @param int    $height Height of the embed in pixels.
     * @param string $url    The URL that should be embedded.
     */
    return apply_filters('embed_defaults', compact('width', 'height'), $url);
}

WordPress Version: 4.0

/**
 * Create 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 'embed_defaults' filter can be used to adjust either of these values.
 *
 * @since 2.9.0
 *
 * @param string $url Optional. The URL that should be embedded. Default empty.
 *
 * @return array Default embed parameters.
 */
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);
    /**
     * Filter the default array of embed dimensions.
     *
     * @since 2.9.0
     *
     * @param int    $width  Width of the embed in pixels.
     * @param int    $height Height of the embed in pixels.
     * @param string $url    The URL that should be embedded.
     */
    return apply_filters('embed_defaults', compact('width', 'height'), $url);
}

WordPress Version: 3.9

/**
 * Create 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 'embed_defaults' filter can be used to adjust either of these values.
 *
 * @since 2.9.0
 *
 * @return array Default embed parameters.
 */
function wp_embed_defaults()
{
    if (!empty($GLOBALS['content_width'])) {
        $width = (int) $GLOBALS['content_width'];
    }
    if (empty($width)) {
        $width = 500;
    }
    $height = min(ceil($width * 1.5), 1000);
    /**
     * Filter the default array of embed dimensions.
     *
     * @since 2.9.0
     *
     * @param int $width  Width of the embed in pixels.
     * @param int $height Height of the embed in pixels.
     */
    return apply_filters('embed_defaults', compact('width', 'height'));
}

WordPress Version: 3.7

/**
 * Create 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 'embed_defaults' filter can be used to adjust either of these values.
 *
 * @since 2.9.0
 *
 * @return array Default embed parameters.
 */
function wp_embed_defaults()
{
    if (!empty($GLOBALS['content_width'])) {
        $width = (int) $GLOBALS['content_width'];
    }
    if (empty($width)) {
        $width = 500;
    }
    $height = min(ceil($width * 1.5), 1000);
    return apply_filters('embed_defaults', compact('width', 'height'));
}