Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

Get Video URL for Video Embed Field - Twig - Drupal 8

The Video Embed Field module is a great tool which can be coupled with any Drupal 8 installation to provide easy and seamless integration of embedded videos from a multitude of hosted service providers.

One common challenge is fetching the raw URL of the video, as specified in the Video Embed Field on your entity type (node, block, etc).

The Video Embed Field module in Drupal 8 provides a way to embed videos out-the-box, and even implement lazy loading and linked thumbnails sourced directly from the service provider.

Unfortunately, there is no display format currently available to serve the raw video URL, or even a link formatter for the video specified in the field.

The solution is quite simple.

First, witch the formatting of the field (under Manage Display) to 'Thumbnail', and set the linked thumbnail to link to the 'Provider URL'.

Then, open up your Twig file, and use the following syntax to render the raw video URL from the Video Embed Field for Drupal 8:

{{ content.field_video.0['#url'] }}

Of course, don't forget to replace the bolded text above with the machine name of your Video Embed field.