A WordPress-centric search engine for devs and theme authors



wp_embed_defaults ›

Since2.9.0
Deprecatedn/a
wp_embed_defaults ( $url = '' )
Parameters:
  • (string) $url Optional. The URL that should be embedded. Default empty.
    Required: No
    Default: (empty)
Returns:
  • (array) Default embed parameters.
Defined at:
Codex:

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.



Source

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 );
}