oEmbed
Last updated
Last updated
The oEmbed field type (e.g. ACF oEmbed field) provides an interactive component for embedding videos, images, tweets, audio, and other content. This field makes use of the native WordPress oEmbed functionality.
Select the oEmbed field from your field group.
Since oembed contains the ready iframe tag, you can add a class attribute using the replace Twig filter, as shown below:
If you've embedded a video, you can enable autoplay so it starts as soon as readers open the page, without needing to click. To do this, add the autoplay
argument to the iframe's src
URL. The argument name may vary depending on the platform, but for YouTube, it's autoplay=1
.
It can be done use the replace Twig filter, as shown below:
By default, the Meta vendors turn the oEmbed field value into an iframe element automatically using the built-in WP feature.
In some cases, you may need to get the raw value, the origin link itself to display alone, not turned into oembed and wrapper into iframe.
In this case, you can use the 'raw_value
' property.
You're free to mix both at the same time, so you can have:
When the first will display the iframe itself, and the second will display the watch link.
Note: for the first case, you should use the 'raw' Twig filter, otherwise the iframe's markup will be escaped.