Fluid Video
Overview
A click-to-play video embed: a poster image with a play button that is swapped for an autoplaying YouTube or Vimeo iframe when clicked, so no player loads until someone asks for it.
- Block name:
method/fluid-video - Title: Fluid Video (Method)
- Category:
method-component-blocks - Supports:
align(wide, full);htmloff - Render type: Dynamic (PHP
render_callback:render_method_fluid_video_block()) - Inner blocks: No
- Scripts:
editorScriptonly. The click handler is assets/js/method-fluid-video.js, concatenated into the theme’sscripts.min.jsbundle (handlemethod), so it is on every page. - Source: lib/blocks/method-fluid-video/method-fluid-video.php, lib/blocks/method-fluid-video/src/edit.js
Usage
Paste a Video URL — any of the YouTube forms (youtube.com/watch?v=, youtu.be/, /embed/, /shorts/, /v/) or Vimeo forms (vimeo.com/123, player.vimeo.com/video/123, channel URLs) — and choose a poster under Image Options. The block renders nothing until it has both: a URL it can parse and a poster image. The play icon, its hover color, the background behind the poster and the Image Shade overlay are set under Color Settings; margins, border, radius and shadow per breakpoint as usual.
On the page the poster is a role="button" link. A click builds the provider’s embed iframe with autoplay on, hides the poster (with hidden, so it leaves the accessibility tree too) and moves focus into the player.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
videoUrl | string | — | The video’s page URL. Parsed on render by method_parse_video_url() into a provider and id; an unparseable URL renders nothing. |
bgImg | object | {"id":""} | The poster, as the media object MethodBackgroundControls stores (id plus the sizes). Rendered with wp_get_attachment_image() at the size in responsiveSettings.base.bgImgSize (default full) with the method-fit-img class. |
linkColor | string | — | Play icon color (labelled Play Icon). |
linkHoverColor | string | — | Play icon hover color (Play Icon (Hover)). |
bgColor | string | — | Background color behind the poster. |
bgGradient | string | — | Background gradient behind the poster. |
bgShadeColor | string | — | Overlay color on the poster (Image Shade). |
bgShadeGradient | string | — | Overlay gradient on the poster. |
responsiveSettings | object | {"base":{"enabled":true},…} | Per-tier spacing, border and shadow; see below. |
responsiveSettings Structure
Per-tier settings live under responsiveSettings.base, mobile, tablet and wide. A tier is only read while its enabled flag is true; base is always on. The keys this block’s CSS map reads:
bgImgSize— base only; the attachment size used for the poster (thumbnail,medium,large,full).margin.top,margin.bottom— on the block wrapper.border,borderRadius— border on the poster link, radius on both the wrapper and the link.shadows— base only (MethodShadowControl), asbox-shadowon the wrapper.
Control Sets
| Component | Panel | Breakpoints | Notes |
|---|---|---|---|
| Block panel: Block Options | Block Options | base | Video URL (TextControl). |
MethodBackgroundControls | Image Options | base | isImg and limited: image selection and size only — no display size, position, parallax or video fallback. |
MethodSpacingControls | Spacing | base + mobile / tablet / wide | include={['margin']}, top and bottom. |
MethodBorderControls | Border | base + mobile / tablet / wide | Border and radius. |
MethodShadowControl | Shadow | base | Multi-layer box shadow. |
MethodColorControls | Color Settings | base | include={['linkColor', 'linkHoverColor', 'bgColor', 'bgShadeColor']} with custom labels: Play Icon, Play Icon (Hover), Image Shade. |
MethodResponsiveTabs | Mobile / Tablet / Ultrawide | mobile, tablet, wide | Spacing and border per tier. |
MethodStyleTag | — | all | Mirrors $cssargs in the canvas. |
Data & Dependencies
method_parse_video_url( $url )(lib/helper-functions.php) — returns[ 'provider' => 'youtube'|'vimeo', 'id' => … ]ornull. YouTube ids are the 11-character token afterwatch?v=,embed/,shorts/,v/oryoutu.be/; Vimeo ids are the numeric id anywhere aftervimeo.com/.method_build_embed_url( $provider, $id )— the iframe URL:https://www.youtube.com/embed/{id}withautoplay=1&rel=0&modestbranding=1&playsinline=1, orhttps://player.vimeo.com/video/{id}withautoplay=1&title=0&byline=0&portrait=0&dnt=1&playsinline=1. Printed on the wrapper asdata-embed-url, with the provider asdata-provider.- Frontend handler (assets/js/method-fluid-video.js) — binds a click on
.method-fluid-video-previewin every.method-fluid-video; on click it appends an iframe (allow="autoplay; encrypted-media; picture-in-picture; fullscreen", a provider-specifictitle) to.method-fluid-video-player, un-hides it, hides the poster, setsdata-active="true"to prevent a second activation, and focuses the player. - Styles (assets/scss/global.scss,
.method-fluid-video) — the player isaspect-ratio: 16 / 9with the iframe absolutely filling it; the poster uses the theme’s.method-fit-img-container/.method-fit-imgcover treatment. - Responsive CSS:
method_get_block_responsive_styles()withmethod_get_responsive_setting()for the image size, collected bymethod_collect_css()under#method-{id}.
Frontend Rendering
<div class="wp-block-method-fluid-video method-fluid-video" id="method-68f1b2c3a4d5e" data-embed-url="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&rel=0&modestbranding=1&playsinline=1" data-provider="youtube">
<a role="button" class="method-fluid-video-preview">
<div class="method-invoke-target"><svg …><!-- play icon --></svg></div>
<div class="method-block-shade"> </div>
<div class="method-fit-img-container">
<img class="method-fit-img" src="…poster.jpg" …>
</div>
</a>
<div class="method-fluid-video-player" hidden></div>
</div>
After a click:
<div class="… method-fluid-video" … data-active="true">
<a role="button" class="method-fluid-video-preview" hidden>…</a>
<div class="method-fluid-video-player" tabindex="-1">
<iframe src="https://www.youtube.com/embed/…?autoplay=1…" class="method-fluid-video__iframe" frameborder="0" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen title="YouTube video player"></iframe>
</div>
</div>
Generated CSS (per instance): #method-{id} → radius, margins, shadow; … > .method-fluid-video-preview → text and background color, radius, border; … > .method-block-shade → shade; … > .method-invoke-target → linkColor, and :hover → linkHoverColor.
Filters
This block exposes no PHP filters. The embed parameters (autoplay, related videos off, modest branding, inline playback; Vimeo with title, byline and portrait off and dnt=1) are fixed in method_build_embed_url().
Changelog
| Version | Description |
|---|---|
| 2.0.0-beta14 | Introduced (ba36676). |
| 2.0.0-beta17 | Inserter title prefixed, “Method Fluid Video” (c34e9bb). |
| 2.0.0-beta21 | Recompiled for the reworked multi-layer MethodShadowControl (75910d2). |
| 2.0.0-beta22 | Retitled “Fluid Video (Method)” and given the method keyword (93e1fcf). |