Skip to content

Conversation

@TremiDkhar
Copy link
Contributor

@coderabbitai
Copy link

coderabbitai bot commented Aug 26, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TremiDkhar TremiDkhar changed the title Add Support for External Videos (#73) [WIP] Add Support for External Videos Aug 26, 2025
@TremiDkhar TremiDkhar marked this pull request as draft August 26, 2025 14:23
Copy link

@gemini-code-assist gemini-code-assist bot left a 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 the core/post-featured-image block. 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.


const setVideoSelection = (media) => {
setMeta({ [META_KEY]: media.id });
const [videoSource, setVideoSource] = useState("upload");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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';
});

* 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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The closing </strong> tag is duplicated in the plugin description. This should be corrected to ensure valid HTML in the plugin header.

 * Description: Add the ability to use Featured Video inplace of Featured Image. <strong>Supported Block: core/post-featured-image</strong>

Comment on lines 117 to 131
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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is duplicated logic for validating the video URL. The check if ( ! $featured_video_url ) and the subsequent return $block_content; appear in both the if and else blocks. Consider refactoring to determine the URL first and then validate it once to avoid repetition and improve maintainability.

Comment on lines 123 to 125
$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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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' )
		);

Comment on lines +13 to +15
onChange={(value) => {
setVideoId(value);
}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The onChange handler can be simplified. Since the handler only calls setVideoId with the value it receives, you can pass setVideoId directly.

Suggested change
onChange={(value) => {
setVideoId(value);
}}
onChange={setVideoId}

@tommusrhodus
Copy link
Contributor

Hey @TremiDkhar ! What's the current status of this work?

@TremiDkhar
Copy link
Contributor Author

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.

@tommusrhodus
Copy link
Contributor

Please tag @nate-allen when this is ready for review :)

@TremiDkhar
Copy link
Contributor Author

Sure thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants