Skip to content

VideoPress: fix video query to only return VideoPress videos#46689

Merged
obenland merged 4 commits intotrunkfrom
fix/videopress-mime-type-filter
Feb 3, 2026
Merged

VideoPress: fix video query to only return VideoPress videos#46689
obenland merged 4 commits intotrunkfrom
fix/videopress-mime-type-filter

Conversation

@obenland
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

jp-launch-control Bot commented Jan 20, 2026

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

paulopmt1
paulopmt1 previously approved these changes Jan 27, 2026
Copy link
Copy Markdown
Contributor

@paulopmt1 paulopmt1 left a comment

Choose a reason for hiding this comment

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

TLDR it looks good, thanks for improving this @obenland! A few notes about testing it.

Tested scenarios on Jetpack self-hosted sites

  • When adding a new video to WordPress library, it doesn't show as loading at Jetpack Videos anymore:

    Before After
    image image
  • Upload and listing Jetpack VideoPress in the free plan works as expected (allows 1 video)

  • It doesn't allow adding more VideoPress videos after the first one, and doesn't allow converting a WordPress video to a VideoPress video after that

  • It allows converting a WordPress video to Jetpack VideoPress if it's the first one. Found a visual improvement here.

Tested scenarios on Dotcom Atomic sites

  1. Tested Atomic sites and it's listing all videos as expected.
  2. Tested simple sites with the free plan, and we can't add videos to them.
  3. Tested on a simple site with a business plan without being atomic, and the listing is working though I wasn't able to convert the video, and this seems to be related to my sandbox as even without this change, it also didn't work. The error was Video height not yet set for guid JHskZll5, so it must be something in my sandbox, as it later worked on Atomic with the changes in the PR.
  4. Tested on a simple site that was converted to Atomic, and it's working as expected.

Though we see it was intentional to list these types of videos, I didn't find any good use for it, so we're good to go.

Note: If you feel it would be good to review item 3 (from Dotcom Atomic tests) in your sandbox, that might be interesting, otherwise, we can test it right after the deployment, as this was a simple site test and the code looks good.

@@ -0,0 +1,126 @@
<?php
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this test! Can we check whether they are running on TeamCity?

Asking that, because other WPCOM VideoPress tests aren't (Linear issue)

Copy link
Copy Markdown
Member Author

@obenland obenland Jan 27, 2026

Choose a reason for hiding this comment

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

I didn't check, but they seem to run in GitHub actions on this PR.

Comment thread projects/packages/videopress/src/class-data.php
Comment thread projects/packages/videopress/tests/php/Data_Test.php
Co-authored-by: Paulo Marcos Trentin <paulo@paulotrentin.com.br>
Copilot AI review requested due to automatic review settings January 27, 2026 23:09
Copy link
Copy Markdown
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

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

@obenland
Copy link
Copy Markdown
Member Author

Tested on a simple site with a business plan

Where in wp-admin did you test this?

@paulopmt1
Copy link
Copy Markdown
Contributor

Tested on a simple site with a business plan

Where in wp-admin did you test this?

In the Library (/wp-admin/upload.php), where Jetpack VideoPress intercepts uploads @obenland.

@obenland obenland merged commit 4d1a401 into trunk Feb 3, 2026
72 checks passed
@obenland obenland deleted the fix/videopress-mime-type-filter branch February 3, 2026 13:44
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] VideoPress [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants