Skip to content

Conversation

@obenland
Copy link
Member

@obenland obenland commented Jan 20, 2026

Before After
Screenshot 2026-01-20 at 3 15 42 PM Screenshot 2026-01-20 at 3 16 08 PM

When viewing the VideoPress library in Jetpack → VideoPress on a site without any VideoPress uploads, local videos (MP4, WebM, etc.) from the media library would incorrectly appear in the library. This happened because the video query included all video mime types instead of filtering to only video/videopress.

Proposed changes:

  • Fix Data::get_video_data() to query only video/videopress mime type instead of all video types
  • The root cause was using both media_type=video AND mime_type=video/videopress in REST API queries - WordPress merges these parameters, resulting in all 16 video mime types being included in the query
  • Remove media_type: 'video' from JS resolvers for VideoPress-specific queries
  • Add PHP tests to verify correct WP_Query parameters

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

N/A

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  1. Upload a regular video (e.g., MP4) to the WordPress media library through Media > Add Media File.
  2. Upload a video via VideoPress.
  3. Go to Jetpack → VideoPress in the admin.
  4. Verify only VideoPress videos appear in the main video library section.
  5. Verify local videos appear only in the "Local videos" section (if applicable).

Automated test verification:

jp test php packages/videopress -- --filter=Data_Test

This runs the new Data_Test which verifies:

  • VideoPress queries use only video/videopress mime type
  • Local video queries use media_type=video with meta_query to exclude VideoPress videos

Remove conflicting media_type parameter when querying for VideoPress videos.
Using both media_type=video and mime_type=video/videopress caused WordPress
REST API to return all video types instead of just VideoPress videos.
Add Data_Test to verify that Data::get_video_data() produces correct
WP_Query parameters:

- VideoPress queries use only video/videopress mime type (not all video types)
- Local video queries use media_type=video with meta_query to exclude
  VideoPress videos

Uses mock plugin pattern from my-jetpack package (assets/*.txt files)
to make Status::is_standalone_plugin_active() return true in tests.
Copilot AI review requested due to automatic review settings January 20, 2026 18:00
@obenland obenland added the [Status] Needs Review This PR is ready for review. label Jan 20, 2026
@obenland obenland self-assigned this Jan 20, 2026
@obenland obenland added the [Status] Needs Review This PR is ready for review. label Jan 20, 2026
@github-actions
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/videopress-mime-type-filter branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/videopress-mime-type-filter

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where VideoPress video queries were incorrectly returning all video types instead of only VideoPress videos. The issue was caused by WordPress merging mime types when both media_type=video and mime_type=video/videopress parameters were used together in REST API queries.

Changes:

  • Modified Data::get_video_data() to use only mime_type=video/videopress for VideoPress queries, removing the redundant media_type=video parameter
  • Updated JavaScript resolvers to remove media_type: 'video' from VideoPress-specific queries while retaining it for local video queries
  • Added comprehensive PHP tests to verify correct query parameters for both VideoPress and local video queries

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/packages/videopress/src/class-data.php Removes media_type parameter from VideoPress queries; only sets it for local video queries along with no_videopress flag
projects/packages/videopress/src/client/state/resolvers.js Removes media_type: 'video' from getVideos and getUploadedVideoCount resolvers (VideoPress queries only)
projects/packages/videopress/tests/php/Data_Test.php Adds unit tests verifying correct WP_Query parameters for VideoPress and local video queries
projects/packages/videopress/tests/php/assets/videopress-mock-plugin.txt Adds mock plugin file for test environment setup
projects/packages/videopress/changelog/fix-videopress-mime-type-filter Documents the bug fix in changelog format

@jp-launch-control
Copy link

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/videopress/src/utility-functions.php 41/270 (15.19%) 0.74% -2 💚
projects/packages/videopress/src/class-wpcom-rest-api-v2-attachment-videopress-data.php 10/105 (9.52%) 9.52% -11 💚
projects/packages/videopress/src/class-attachment-handler.php 15/89 (16.85%) 16.85% -15 💚
projects/packages/videopress/src/class-data.php 32/252 (12.70%) 12.70% -32 💚

Full summary · PHP report · JS report

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants