I have found a solution for QUARK that works and is right for me. “Code is poetry” does not apply to my proposal
I assume that you are working with a child theme (mytheme).
mytheme → templates → modular → videohero.html.twig:
{% set grid_size = theme_var('grid-size') %}
{% set hero_image = page.header.hero_image ? page.media[page.header.hero_image] : page.media.images|first %}
{% include 'partials/videohero.html.twig' %}
mytheme → templates → partials → videohero.html.twig:
<section id="{{ id }}" class="section modular-hero hero {{ page.header.hero_classes }} {{ page.header.background.parallax ? 'parallax' : '' }}" style="padding: 0;">
<!-- Background video -->
<div class="video-background-holder">
<div class="video-background-overlay"></div>
<video playsinline="playsinline" autoplay="autoplay" muted="muted" loop="loop">
<source src="{{ page.url|e }}/{{ page.header.video_mp4 }}" type="video/mp4">
</video>
<div class="video-background-content container h-100">
<div class="image-overlay" style="height: 100vh; padding-top: 5rem;"></div>
<section class="container {{ grid_size }}" style="text-align: {{ page.header.hero_align|default('center') }}">
<br>
{{ content|raw }}
</section>
</div>
</div>
</section>
mytheme → css → custom.css:
.video-background-holder {
position: relative;
background-color: black;
height: calc(100vh - 72px);
min-height: 25rem;
width: 100%;
overflow: hidden;
}
.video-background-holder video {
position: absolute;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: 0;
-ms-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
.video-background-content {
position: relative;
z-index: 2;
}
.video-background-overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: black;
opacity: 0;
z-index: 1;
}
mytheme → blueprints → modular → videohero.yaml (sorry, i forgot the blueprint when i first published my solution)
title: Hero
'@extends': default
form:
fields:
tabs:
fields:
buttons:
type: tab
title: Hero
fields:
header.hero_classes:
type: text
label: Hero Classes
markdown: true
description: 'There are several Hero class options that can be listed here (space separated):<br />`text-light`, `text-dark`, `title-h1h2`, `parallax`, `overlay-dark-gradient`, `overlay-light-gradient`, `overlay-dark`, `overlay-light`, `hero-fullscreen`, `hero-large`, `hero-medium`, `hero-small`, `hero-tiny`<br />Please consult the [Quark documentation](https://github.com/getgrav/grav-theme-quark#hero-options) for more details.'
header.hero_image:
type: filepicker
label: Hero Image
preview_images: true
description: 'If not specified, this defaults to the first image found in the page''s folder'
header.video_mp4:
type: text
label: Background Video (mp4 Format)
help: URL to a mp4 video which is used as background video. If background video is played, we don't see background image.
Hope, it works