Skip to content
Radoslav Georgiev edited this page Sep 3, 2016 · 1 revision

The Rila\Embed class is a simple wrapper to the wp_oembed_get function.

Creating an embed object

To create a new embed, use the rila_embed( $url ) function:

$embed = rila_embed( 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' );

The URL parameter should be from a website, which is among the WordPress-supported embed providers.

Template usage

Within templates, you can simply output the embed. It will be converted to the needed string.

{{ post.video }}

Dimensions

You can use the width( $width ) and height( $height ) methods to manipulate the dimensions of the embed.

Please keep in mind, that only pixels heights are supported here. However, if you set a width, you can leave the height to be auto-adjusted. This way, WordPress will load the height automatically.

Full example:

{{ post.video.width( 1280 ).height( 720 ) }}

Sufficient example:

{{ post.video.width( 800 ) }}

Mapping

When using data mapping, you can use the embed shortcut to quickly map an URL to an embed.


Next article: Request Variables