Feat: update video block in elementor - #2044
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Updates the GoDAM Video Elementor widget to add a transcription toggle, improve editor-preview parity (static overlay indicators), and standardize editor-preview styling via a dedicated preview-iframe stylesheet.
Changes:
- Added a Show Transcription control and wired it through to the player render attributes.
- Added editor-preview-only UI improvements: static overlay indicators and a consistent empty state for the Video widget.
- Moved multiple widgets’ editor-preview styling into a new preview iframe stylesheet and fixed thumbnail-picker timing with a bounded poll.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| inc/classes/elementor-widgets/class-godam-video.php | Adds transcription control, editor overlay rendering, and a video empty state. |
| inc/classes/elementor-widgets/class-godam-image.php | Removes inline empty-state styles and switches to CSS custom property + shared preview stylesheet. |
| inc/classes/elementor-widgets/class-godam-gallery.php | Removes inline empty-state styles in favor of the shared preview stylesheet. |
| inc/classes/elementor-widgets/class-godam-audio.php | Replaces inline styles with class-based styling + CSS custom property for the icon. |
| inc/classes/class-elementor-widgets.php | Enqueues the built preview stylesheet into the Elementor preview iframe. |
| assets/src/js/elementor/editor.js | Replaces fixed-delay thumbnail picker render with bounded polling + keeps autoplay lock behavior. |
| assets/src/css/godam-elementor-preview.scss | New SCSS for preview-iframe-only empty states and the video overlay UI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'sources' => isset( $widget_video_file['sources'] ) ? $widget_video_file['sources'] : array(), | ||
| 'src' => $widget_video_file['url'], | ||
| 'transcoded_url' => '', | ||
| 'poster' => $widget_poster_file['url'], |
Code review — PR #2044Reviewed the diff (Elementor Video widget transcription toggle, editor-preview overlay parity, thumbnail-picker fix, and the dedicated preview stylesheet). Nicely documented change overall — the caching/poll rationale and the "why static indicators" write-up made this easy to follow. A few things worth a look, roughly by severity: 1. Transcription now defaults off — silent regression for already-published widgets
|
Feat: GoDAM Video (Elementor) — transcription toggle, editor-preview parity, and a dedicated preview stylesheet
Issue - rtCamp/godam-plugin-wp#21
Summary
Rounds out the GoDAM Video Elementor widget and cleans up the editor-preview styling shared by all GoDAM Elementor widgets. Highlights:
<style>blocks into a dedicated, built stylesheet enqueued into the preview iframe.What changed
Video widget —
inc/classes/elementor-widgets/class-godam-video.phpshow_transcription), mapped to the block'sshowTranscriptionattribute in the render array (the shared player template already reads it). Bothshow_share_buttonandshow_transcriptionnow default to off ('').render()wraps the player and overlays static top-right share and transcript icons (same SVGs the Gutenberg block editor uses) when the respective toggle is on — transcript on top, share below it when both are on. The live player only adds these to the video.js control bar (and gates the transcript button on an actual transcript), so they wouldn't reliably show while designing; the static indicators guarantee parity with the block editor. The live control-bar buttons are hidden inside the preview wrapper so nothing duplicates. The published front end is untouched — it still uses the real player, andshowShareButton/showTranscriptionare passed through to it.is_editor_preview()andrender_editor_button_overlay().Thumbnail picker fix —
assets/src/js/elementor/editor.jsThe "Or pick an auto-generated thumbnail" grid sometimes never populated.
hydrateWidget()scheduled the render with a singlesetTimeout(100), but Elementor injects the conditional RAW_HTML picker control into the panel DOM asynchronously — if it wasn't there at 100 ms,renderThumbnailPicker()bailed and nothing re-triggered it (a passive panel open fires no settings change). Replaced the fixed delay with a bounded poll (up to ~2 s) that waits for the container, then renders once, and bails if the panel has since switched widgets. Side benefit: videos with no auto-thumbnails now correctly show the "none available" message instead of a blank gap.Dedicated preview stylesheet —
assets/src/css/godam-elementor-preview.scss(new)Previously the editor-preview affordances (empty states + the video overlay) used inline
<style>blocks / inlinestyle=""attributes, because the widgets render inside Elementor's preview iframe, where the plugin's editor-panel stylesheet (godam-elementor-editor.css, enqueued in the editor's main window) isn't loaded.Moved all of that CSS into a dedicated SCSS that auto-builds to
assets/build/css/godam-elementor-preview.css(any non-_file inassets/src/css/is picked up by the webpackstylesconfig — no config change needed), and enqueue it into the preview iframe viaelementor/preview/enqueue_styles. It covers the video overlay and the image / gallery / audio / video empty states.Dynamic icon URLs (which depend on
RTGODAM_URL, so they can't be hard-coded in a static SCSS) are passed per-element via a--godam-preview-iconCSS custom property, which the SCSS consumes withbackground-image: var(--godam-preview-icon).Enqueue + cleanup —
inc/classes/class-elementor-widgets.phpenqueue_preview_styles()hooked toelementor/preview/enqueue_styles(guarded on the built file existing).Consistency cleanup across sibling widgets
Removed the inline
<style>blocks / inlinestyleattributes from the Image, Gallery, and Audio empty states (class-godam-image.php,class-godam-gallery.php,class-godam-audio.php) and pointed them at the new stylesheet +--godam-preview-iconproperty. No visual change — just the same styling from a maintainable, built source.Why static indicators instead of the live player buttons (editor only)
The live GoDAM player adds share/transcript to the video.js control bar and gates the transcript button on a fetched transcript (
data-job_id) — reasonable at runtime, but it means the buttons don't reliably show while an author is designing. The block editor solves this with persistent static top-right icons; this PR mirrors that in the Elementor preview so the two editors look the same. Front-end rendering is unchanged.Build
The SCSS and
editor.jschanges require a build:assets/build/**is gitignored, so reviewers must rebuild locally. The PHP changes (widget controls, render, enqueue) don't need a build on their own, but the preview stylesheet + thumbnail-picker fix do.Testing
Show Transcription + overlay parity (editor preview)
Thumbnail picker
7. Open a Video widget whose video has auto-generated thumbnails → the "Or pick an auto-generated thumbnail" grid fills; clicking a tile sets the poster.
8. A video with no auto-thumbnails → shows "No auto-generated thumbnails available…" instead of a blank gap.
9. Switch quickly between two video widgets → the correct grid shows for the open one.
Preview stylesheet / other widgets
10. Image / Audio / Gallery / Video empty states still render correctly in the Elementor preview (styling now comes from the enqueued stylesheet).
11. Confirm nothing new loads or renders on the published front end.
Related
Part of the GoDAM page-builder rollout (Video, Video Gallery, Audio, Document, Image across WPBakery and Elementor).
Demo
Screen.Recording.2026-07-27.at.5.48.37.PM.mov