wp embed fetch
Attempts to convert a URL into embed HTML.
In non-raw mode, starts by checking the URL against the regex of the registered embed handlers. If none of the regex matches and it’s enabled, then the URL will be given to the WP_oEmbed class.
In raw mode, checks the providers directly and returns the data.
Synopsis
wp embed fetch <url> [--width=<width>] [--height=<height>] [--post-id=<id>] [--discover] [--skip-cache] [--skip-sanitization] [--do-shortcode] [--limit-response-size=<size>] [--raw] [--raw-format=<json|xml>]
Options
<url>
: URL to retrieve oEmbed data for.
[–width=<width>]
: Width of the embed in pixels.
[–height=<height>]
: Height of the embed in pixels.
[–post-id=<id>]
: Cache oEmbed response for a given post.
[–discover]
: Enable oEmbed discovery. Defaults to true.
[–skip-cache]
: Ignore already cached oEmbed responses. Has no effect if using the ‘raw’ option.
[–skip-sanitization]
: Remove the filter that WordPress from 4.4 onwards uses to sanitize oEmbed responses. Has no effect if using the ‘raw’ option.
[–do-shortcode]
: If the URL is handled by a registered embed handler and returns a shortcode, do shortcode and return result.
[–limit-response-size=<size>]
: Limit the size of the resulting HTML when using discovery. Default 150 KB. Not compatible with ‘no-discover’.
[–raw]
: Return the raw oEmbed response instead of the resulting HTML. Ignores the cache and does not sanitize responses.
[–raw-format=<json|xml>]
: Render raw oEmbed data in a particular format. Defaults to json. Can only be specified with the ‘raw’ option.
Examples
# Get embed HTML for a given URL.
$ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ
<iframe width="525" height="295" src="https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed" ...
# Get raw oEmbed data for a given URL.
$ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ --raw
{"author_url":"https://www.youtube.com/user/RickAstleyVEVO","width":525,"version":"1.0", ...