-
Notifications
You must be signed in to change notification settings - Fork 8
[WIP] Add Support for External Videos #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
[WIP] Add Support for External Videos #94
Conversation
TremiDkhar
commented
Aug 26, 2025
- Added: Add embed support ([Blocks Monorepo] Post Featured Video #73)
- Update package-lock.json
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @TremiDkhar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the 'Featured Video' plugin by introducing support for external video embeds. Previously, only videos uploaded to the WordPress Media Library could be used. Now, users can seamlessly integrate videos from popular platforms like YouTube and Vimeo by simply providing their URLs. The underlying code has been updated to handle both local and external video sources, including changes to the post meta field and rendering logic. The editor's user interface has also been refactored to provide a clear choice between these two video source options, making the plugin more versatile and user-friendly.
Highlights
- External Video Support: The plugin now supports using external video URLs (e.g., YouTube, Vimeo) as featured videos, in addition to videos uploaded to the WordPress Media Library. This is achieved by updating the post meta field to accept string URLs and using WordPress's oEmbed capabilities for rendering.
- Enhanced Editor UI: The editor interface for selecting featured videos has been revamped. Users can now choose between uploading a video from the media library or providing an external video URL via a new input field, improving flexibility and user experience.
- Version Update and Dependency Management: The plugin's version has been bumped to
0.2.0, and the description updated to clarify its compatibility with thecore/post-featured-imageblock. Several development dependencies have also been updated to their latest versions.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully adds support for using external videos as featured videos, complementing the existing media library functionality. The code is well-structured, separating the UI into distinct components for local and external video sources. I've identified a high-severity bug related to the initial state of the video source selector in the editor, which could affect the user experience when editing posts with existing external videos. Additionally, I've left a few medium-severity comments regarding a minor HTML error, a missing translation, and opportunities to simplify and deduplicate code in both PHP and JavaScript files. Addressing these points will enhance the robustness and maintainability of this new feature.
featured-video/src/editor/index.js
Outdated
|
|
||
| const setVideoSelection = (media) => { | ||
| setMeta({ [META_KEY]: media.id }); | ||
| const [videoSource, setVideoSource] = useState("upload"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The videoSource state is always initialized to "upload". If a post already has an external video URL saved, this will cause the UI to show the "Media Library" controls instead of the "External Video" URL input when the editor loads. The initial state should be determined based on the value of selectedVideoId.
| const [videoSource, setVideoSource] = useState("upload"); | |
| const [videoSource, setVideoSource] = useState(() => { | |
| // If it's a non-numeric string, assume it's an external URL. | |
| if (selectedVideoId && !/^\d+$/.test(selectedVideoId)) { | |
| return 'external'; | |
| } | |
| // Default to 'upload' for numeric IDs or when no video is set. | |
| return 'upload'; | |
| }); |
featured-video/featured-video.php
Outdated
| * Plugin Name: Featured Video | ||
| * Description: Add the ability to use Featured Video inplace of Featured Image. | ||
| * Version: 0.1.3 | ||
| * Description: Add the ability to use Featured Video inplace of Featured Image. <strong>Supported Block:</strong> core/post-featured-image</strong> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
featured-video/featured-video.php
Outdated
| if ( ! $featured_video_url ) { | ||
| return $block_content; | ||
| } | ||
|
|
||
| $featured_video_url = esc_url_raw( $featured_video_url ); | ||
|
|
||
| $video_markup = <<<HTML | ||
| <video class="attachment-post-thumbnail size-post-thumbnail wp-post-image wp-post-video intrinsic-ignore" controls autoplay muted loop playsinline src="$featured_video_url" style="width: 100%" preload="metadata"><p>Your browser does not support the video tag.</p></video> | ||
| HTML; | ||
| } else { | ||
| $featured_video_url = esc_url_raw( $featured_video_id ); | ||
|
|
||
| if ( ! $featured_video_url ) { | ||
| return $block_content; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $video_markup = <<<HTML | ||
| <video class="attachment-post-thumbnail size-post-thumbnail wp-post-image wp-post-video intrinsic-ignore" controls autoplay muted loop playsinline src="$featured_video_url" style="width: 100%" preload="metadata"><p>Your browser does not support the video tag.</p></video> | ||
| HTML; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback text for the <video> tag is not internationalized. This was handled in the previous version of the code. Please use esc_html__() to make this string translatable.
$video_markup = sprintf(
'<video class="attachment-post-thumbnail size-post-thumbnail wp-post-image wp-post-video intrinsic-ignore" controls autoplay muted loop playsinline src="%s" style="width: 100%%" preload="metadata"><p>%s</p></video>',
$featured_video_url,
esc_html__( 'Your browser does not support the video tag.', 'featured-video' )
);| onChange={(value) => { | ||
| setVideoId(value); | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hey @TremiDkhar ! What's the current status of this work? |
|
Hello @tommusrhodus, I'm currently working on some other project. My plan is got this done within 2-3 week. Only few adjustment is needed and testing too. |
|
Please tag @nate-allen when this is ready for review :) |
|
Sure thanks 👍 |