Twig get Media Video Width and Height

Created on 29 September 2023, about 1 year ago
Updated 13 October 2023, about 1 year ago

Problem/Motivation

I made one paragraph with a field of type media video. Now in twig (paragraph--paragraph-video.html.twig) I want the width and height of the referenced video (not the thumbnail) so I can create my own video template attributes.

I could store the video url in variable video_url
I want the width and height to get filled in paragraph--paragraph-video.html.twig from the video dimensions:

  {% set video_url = file_url(paragraph.field_paragraph_video.entity.field_media_video_file.entity.fileuri) %}
  {% set width=??? %}
  {% set height=??? %}

 <video  width="{{ width }}" height="{{ height }}">
  <source src="{{ video_url }}" type="video/mp4">

 </video>
💬 Support request
Status

Active

Version

1.16

Component

Documentation

Created by

🇩🇪Germany thomaswalther Rhein-Main Area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024