wp_embed_defaults

Creates default array of embed parameters.

Description

(array) wp_embed_defaults( (string) $url = '' ); 

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 filter can be used to adjust either of these values.

Returns (array)

Default embed parameters.

Parameters (1)

0. $url — Optional. (string) => ''
The URL that should be embedded. Default empty.

Usage

  1. if ( !function_exists( 'wp_embed_defaults' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // Optional. The URL that should be embedded. Default empty. 
  5. $url = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_embed_defaults($url); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/embed.php  
  1. function wp_embed_defaults( $url = '' ) { 
  2. if ( ! empty( $GLOBALS['content_width'] ) ) 
  3. $width = (int) $GLOBALS['content_width']; 
  4.  
  5. if ( empty( $width ) ) 
  6. $width = 500; 
  7.  
  8. $height = min( ceil( $width * 1.5 ), 1000 ); 
  9.  
  10. /** 
  11. * Filters the default array of embed dimensions. 
  12. * @since 2.9.0 
  13. * @param array $size An array of embed width and height values 
  14. * in pixels (in that order). 
  15. * @param string $url The URL that should be embedded. 
  16. */ 
  17. return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url );