Media Manager Design
This document tracks the evolving design of the Media Manager plugin.
Completed
Section titled “Completed”-
Foundation: Git repo, plugin bootstrap (
mediamanager.php), Composer + PHPUnit + Brain\Monkey, npm + Vitest setup. -
Taxonomy:
media_folderhierarchical taxonomy on attachments, with tests inTaxonomyTest.php. -
Smart Suggestions:
- Backend:
MediaManager\Suggestionsstores_mm_folder_suggestionsbased on MIME type, EXIF created timestamp, and IPTC keywords on upload (wp_generate_attachment_metadatawithcontext === 'create'). - UI:
SuggestionNoticeReact component shows inline notice with suggested folders and Apply / Dismiss actions.
- Backend:
-
Tree View UI:
src/admin/media-library.js: Hooks intowp.media.view.AttachmentsBrowserto inject React folder tree sidebar.src/admin/components/FolderTree.jsx: Renders hierarchical folder list with “All Media” and virtual “Uncategorized” filters.includes/class-admin.php: Enqueues admin JS/CSS on Media Library pages (upload.php,media-new.php).- URL state management via
?mm_folder=<id>query param. - Vitest tests in
tests/js/FolderTree.test.jsxwith@vitejs/plugin-reactfor JSX transformation. - PHPUnit tests in
tests/php/AdminTest.php.
-
Drag-and-Drop Organization:
- Native HTML5 drag-and-drop in
media-library.jsfor dragging media to folders. DroppableFolder.jsx: Makes folder tree items valid drop targets.MoveToFolderMenu.jsx: Keyboard-accessible dropdown menu alternative to drag-and-drop.FolderTree.jsx: Uses@dnd-kit/sortablefor folder reordering.- Tests in
DragDrop.test.jsxandMoveToFolderMenu.test.jsx.
- Native HTML5 drag-and-drop in
-
Gutenberg Integration:
src/editor/components/FolderFilter.jsx: Dropdown component for filtering media by folder in block editor.src/editor/components/MediaUploadFilter.jsx: EnhancedMediaUploadwrapper usingaddFilteroneditor.MediaUpload.src/editor/index.js: Entry point that registers filters and extendswp.media.view.MediaFrame.src/editor/styles/editor.css: Editor-specific styles for folder filter UI.includes/class-editor.php: Enqueues editor scripts onenqueue_block_editor_assets, filtersajax_query_attachments_argsfor folder/uncategorized filtering.- Tests in
tests/js/editor/FolderFilter.test.jsxandtests/js/editor/MediaUploadFilter.test.jsx. - PHP tests in
tests/php/EditorTest.php.
-
REST API:
includes/class-rest-api.php: Custom REST API endpoints undermediamanager/v1namespace.- Folder endpoints:
GET/POST /folders,GET/PUT/DELETE /folders/{id},POST/DELETE /folders/{id}/media. - Suggestion endpoints:
GET /suggestions/{media_id},POST /suggestions/{media_id}/apply,POST /suggestions/{media_id}/dismiss. - Permission checks for
upload_filesandmanage_categoriescapabilities. - Tests in
tests/php/RestApiTest.php.
-
CI Workflow:
.github/workflows/ci.yml: GitHub Actions workflow.- PHP tests on PHP 8.3 and 8.4 with Composer caching.
- JavaScript tests on Node.js 20 and 22 with npm caching.
- Build job that produces artifacts after tests pass.
-
Bulk Folder Assignment:
src/admin/components/BulkFolderAction.jsx: Dropdown to assign multiple selected media to a folder.- Integrated into FolderTree sidebar, shows when media items are selected.
- Supports moving to any folder or removing from all folders (Uncategorized).
-
Folder Management UI:
src/admin/components/FolderManager.jsx: Create, rename, delete folder buttons with Modal dialogs.- Icon-only buttons with screen reader text for accessibility.
- Uses SlotFillProvider for proper Modal rendering.
- Delete confirmation with warning when folder contains media.
- Integrated into FolderTree sidebar header.
-
Gutenberg Media Modal Sidebar:
src/editor/components/FolderSidebar.jsx: Folder tree sidebar for Gutenberg media modal.- Replaces dropdown filter with full sidebar navigation.
- Integrated with wp.media.view.MediaFrame for modal context.
- Consistent UI with Media Library folder tree.
-
UI/UX Improvements:
- Folder toggle button: PHP-rendered
<a>linking toupload.php?mode=folder, positioned before view switcher. - View switching handled server-side: PHP reads
$_GET['mode']onload-upload.phpto toggle sidebar preference in user meta. - Sidebar preference stored in
vmfo_sidebar_visibleuser meta (replaces localStorage). - Activation hook defaults sidebar to visible for the activating user.
- REST endpoint
POST /vmfo/v1/preferencesfor programmatic preference updates. - Auto-expand parent folders when child folder is selected.
- Smooth loading transitions when switching folders (opacity fade).
- Empty folder handling with min-height to prevent sidebar collapse.
- Hide uploader overlay when viewing filtered folders.
- Auto-select folder after drag-drop move operation.
- Folder toggle button: PHP-rendered
-
Settings Page:
includes/class-settings.php: Plugin settings page under Media menu.- Smart Suggestions options: enable/disable, MIME type matching, EXIF date, IPTC keywords.
- Default behavior: default folder assignment, show/hide Uncategorized.
- UI preferences: enable/disable drag-drop, sidebar default visibility.
-
Internationalization:
languages/mediamanager.pot: Generated POT file for translations.- All user-facing strings use
__()orsprintf()with translator comments. - npm scripts:
i18n:make-potandi18n:make-jsonfor translation workflow.
In Progress
Section titled “In Progress”- WordPress 7.0+ UI/UX Compatibility:
- WP 7 ships a visual reskin (“coat-of-paint”) with the Modern color scheme as default (
#3858e9theme color). New design tokens for grays, radii, button heights, and elevation. - Approach: Separate
wp7-compat.cssoverride files (admin + editor), conditionally loaded viavmfo_is_wp7()helper when WP ≥ 7.0. - Theme color: All hardcoded
#007cba/#2271b1replaced withvar(--wp-admin-theme-color)and related custom properties so the plugin respects any admin color scheme. - Design tokens aligned: sidebar bg
#f6f7f7→#f0f0f0, borders#dcdcde→#ddd, modalborder-radius: 8px. - Dependencies: WP7 stylesheets declare
wp-base-stylesas a CSS dependency to guarantee custom properties are available. - Critical CSS:
add_critical_css()also emits WP 7 sidebar overrides to prevent layout shift. - Backward compatible: Base stylesheets remain untouched; WP 6.x sees no change.
- WP 7 ships a visual reskin (“coat-of-paint”) with the Modern color scheme as default (
- User documentation / README.
- Plugin release workflow (GitHub releases, version bumping).
- Integration with third-party DAM (Digital Asset Management) systems.
📦 Source: soderlind/virtual-media-folders · Edit on GitHub