Skip to content

Media picker shows All Media 0 and a failed request when limited to caption or document files #2239

Closed

Description

@subodhr258

Parent: https://github.com/rtCamp/godam-plugin-wp/issues/23 · Owner: @subodhr258 · Release: 2.5.2 (https://github.com/rtCamp/godam-plugin-wp/issues/66) · Reported by: @kishan-gondaliya-7270

Fix PR: #2258

What it is

When a media picker is limited to caption files or documents, the GoDAM folder sidebar shows All Media 0, even when matching files exist. The request behind that number fails with HTTP 400, and the failure shows in the browser's Network tab.

Picking a file still works. The count is wrong and the failed request looks like a broken feature to anyone with DevTools open. This is not new in 2.5.0: it has been there since 1.10.0 (December 2025).

Picker Files it allows All Media request Sidebar shows
Video editor, Transcription tab, Upload File or Replace .vtt, .srt, .txt 400 0, with 1 caption file in the library
Document block PDF, Word, Excel and other documents 400 0 (checked through the REST route, not in the browser)
Video, audio and image pickers one whole type, such as video 200 the right number

Steps to reproduce

  1. Upload one .vtt file to the Media Library.
  2. Open the GoDAM video editor for any video, go to the Transcription tab and click Upload File (or Replace).
  3. In the picker's left sidebar, All Media shows 0 while Uncategorized shows 1.
  4. In DevTools > Network, wp/v2/media?_fields=id&per_page=1&media_type=text/vtt,application/x-subrip,text/plain returns 400 with media_type[0] is not one of image, video, text, application, and audio.

Expected: All Media shows 1 and no request fails.

The GoDAM tab in the same picker says "No items found". That is expected and not part of this bug: caption files are stored only in the WordPress Media Library, never in GoDAM cloud storage.

Cause

WordPress's media REST route takes two filters:

Filter Accepts Example
media_type only whole types video, text, application
mime_type only exact file types text/vtt, application/pdf

The sidebar always sends the picker's file types as media_type. That works for video, but WordPress rejects exact file types such as text/vtt with a 400.

Fix

When the filter has exact file types (with a /), count through admin-ajax query-attachments, the query the picker's own grid runs. Whole types and no filter stay on the REST route. Sending the list as mime_type instead only works from WordPress 6.9, and GoDAM supports 6.5. This is one function in the media library sidebar, plus unit tests.

Who builds what

@subodhr258: the fix, the test, and a check in the caption picker, the Document block picker and the normal Media Library page.

Estimate

About 2 hours of work. It ships with 2.5.2.

For agents / implementers
  • Bad call: pages/media-library/redux/api/folders.js:71, getAllMediaCount uses getCurrentMimeTypeFilter( 'media_type' ) (pages/media-library/data/utilities.js:221), which passes the frame's library.type (or the post_mime_type URL param) straight through.

  • Callers that send exact file types: pages/video-editor/components/transcription/Transcription.js:136 ([ 'text/vtt', 'application/x-subrip', 'text/plain' ]) and the Document block's MediaUpload allowedTypes={ ALLOWED_MEDIA_TYPES } (assets/src/blocks/godam-pdf/constants.js, the keys of SUPPORTED_DOCUMENT_TYPES).

  • Core (WordPress 7.1.3, wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php): media_type is an array whose items are the enum image, video, text, application, audio. mime_type is an array of strings, and prepare_items_query() keeps an entry only when it is an exact allowed file type. A whole type such as video sent as mime_type is silently dropped, so the count becomes every attachment (checked: mime_type=video returned 70 of 70). So split, do not just rename the parameter.

  • Checked on godam-dev, GoDAM 2.5.0 (d9b98889), as admin with the REST nonce:

    Query Status X-WP-Total
    media_type=text/vtt,application/x-subrip,text/plain 400
    media_type=application/pdf 400
    media_type=video 200 60
    mime_type=text/vtt,application/x-subrip,text/plain (one .vtt uploaded) 200 1
    mime_type=application/pdf 200 1
  • getCategoryMediaCount and getFolders send the same value as post_mime_type to GoDAM's own routes, which accept exact file types (Uncategorized showed 1), so they need no change.

  • type can be a string, a comma list or an array. Normalise first, then split on whether each entry contains /. Also try the Media Library page's Documents, Spreadsheets and Archives filters, which use lists of exact file types (not checked).

  • Introduced by 3e75be8 (Media library extended issues #1353, 2025-12-05), first tagged 1.10.0.

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. kishan-gondaliya-7270 commented on Oct 28, 2026

    @kishan-gondaliya-7270
    Collaborator

    GoDAM Core doesn't support vtt file

    Image
  3. added a commit that references this issue on Nov 1, 2026
    1f8fcce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions