Media browser (2.4): upload-into-folder only works for HappyFiles, not for custom media folder providers

Bricks version: 2.4

I registered a custom media folder provider through the new API (bricks/media_folder_providers/register, class implementing \Bricks\Media_Folder_Provider). It maps an existing media taxonomy to Bricks folders.

Almost everything works: the folder tree, counts, filtering, “Uncategorized”, create/rename/move/delete, and Move.

The problem: uploading a file while a folder is open always puts it in “Uncategorized”. The folder is never sent to the server.

Cause: the builder JS (assets/js/main.min.js) is hard-coded to HappyFiles:

  • mediaUploadHappyFilesFolderId returns 0 unless mediaFolderProvider.id === 'happyfiles', so no folder ID is sent for any other provider.
  • The upload and “import from URL” requests always send bricksMediaFolderProvider: "happyfiles", not the active provider’s ID.

The PHP side is already provider-neutral: Media_Browser_Upload::assign_requested_folder() compares bricksMediaFolderProvider against the active provider’s get_id(). It never matches, because the JS always sends happyfiles.

Suggested fix: in the JS, use the active provider (mediaFolderProvider.id) instead of the happyfiles literal, both when reading the open folder and for the bricksMediaFolderProvider request parameter.

Steps to reproduce:

  1. Register a custom provider with any ID other than happyfiles.
  2. Open the media browser, open a folder, and upload a file.
  3. The file lands in “Uncategorized”, and the provider’s assign_attachment() is never called.