6.2 KiB
6.2 KiB
Media Library Quick Reference
Opening the Media Library
Navigate to: http://localhost:5000/admin/media-library.html
Interface Overview
┌─────────────────────────────────────────────────────────────┐
│ Media Library [X] │
├─────────────────────────────────────────────────────────────┤
│ 🏠 Root 0 selected │
│ [🗂️ New Folder] [☁️ Upload Files] [🗑️ Delete Selected] │
├─────────────────────────────────────────────────────────────┤
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ 📁 │ │ 🖼️ │ │ 🖼️ │ │ 🖼️ │ │
│ │MyFolder│ │image1 │ │image2 │ │image3 │ │
│ │ 5 files│ │ │ │ │ │ │ │
│ └────────┘ └────────┘ └────────┘ └────────┘ │
│ │
│ [Upload Zone - Hidden by default] │
│ ☁️ Drop files here or click to browse │
│ Supported: JPG, PNG, GIF, WebP (Max 5MB each) │
│ │
│ [Progress Bar - Shows during upload] │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░ 65% │
└─────────────────────────────────────────────────────────────┘
Actions
Upload Files (Method 1: Click)
- Click "Upload Files" button
- Upload zone appears
- Click anywhere in the drop zone
- File picker opens
- Select one or more images
- Progress bar shows upload status
- Success alert: "Successfully uploaded X file(s)!"
- Files appear in the grid
Upload Files (Method 2: Drag & Drop)
- Click "Upload Files" button
- Upload zone appears
- Drag files from your file manager
- Drop onto the blue upload zone
- Progress bar shows upload status
- Success alert appears
- Files appear in the grid
Create New Folder
- Click "New Folder" button
- Modal appears: "Create New Folder"
- Enter folder name (e.g., "Products", "Logos", "Banners")
- Click "Create Folder"
- Success alert: "Folder 'Products' created successfully!"
- Folder appears in the grid with 📁 icon
Navigate Folders
- Double-click a folder to open it
- Breadcrumb at top shows current path:
🏠 Root > Products > Summer - Click breadcrumb links to go back to parent folders
Select Items
- Click checkbox on any file or folder to select
- Selected count shows: "3 selected"
- Delete Selected button appears when items are selected
Delete Items
- Select one or more files/folders using checkboxes
- Click "Delete Selected" button
- Confirm deletion
- Items are removed
Browser Console
Open Developer Tools (F12) and check Console tab for detailed logs:
Normal Flow
Initializing media library...
Loaded folders: 2
Loaded files: 5
Media library initialized
Upload Flow
Upload zone opened
Files selected: 2
Starting upload of 2 files
Adding file: photo.jpg image/jpeg 1234567
Adding file: banner.png image/png 987654
Sending upload request...
Upload progress: 50%
Upload progress: 100%
Upload complete, status: 200
Upload response: {success: true, files: Array(2)}
Folder Creation
Creating folder: MyFolder in parent: null
Create folder response: {success: true, folder: {...}}
Error Examples
Failed to load folders: Authentication required
// → Will redirect to login page
Upload failed: File type not allowed
// → Shows error alert
Failed to create folder: A folder with this name already exists
// → Shows error alert
Error Messages
Upload Errors
- "No files to upload" - No files selected
- "File type not allowed" - Invalid file type (only JPG, PNG, GIF, WebP)
- "File too large" - File exceeds 5MB limit
- "Upload failed with status 413" - Request too large
- "Upload failed due to network error" - Network connection issue
- "Authentication required" - Session expired, will redirect to login
Folder Errors
- "Please enter a folder name" - Empty folder name
- "A folder with this name already exists" - Duplicate name in same location
- "Parent folder not found" - Parent folder was deleted
- "Authentication required" - Session expired
File Support
Supported Formats
- ✅ JPEG/JPG
- ✅ PNG
- ✅ GIF
- ✅ WebP
File Limits
- Max file size: 5 MB per file
- Max files per upload: 10 files at once
- Total upload size: 50 MB per batch
File Naming
- Original names preserved in database
- Filenames sanitized and made unique
- Format:
name-timestamp-random.ext - Example:
photo-1734657890-123456789.jpg
Tips
- Use folders to organize your media by category (products, logos, banners, etc.)
- Check console logs (F12) if something doesn't work as expected
- File uploads show progress - don't navigate away during upload
- Double-click folders to navigate, single-click to select
- Breadcrumbs at the top help you navigate back to parent folders
- Select multiple items using checkboxes for batch deletion
Integration with Homepage Editor
When you click "Choose Image" in the homepage editor:
- Media library opens in a modal
- Select an image
- Click "Select" or double-click the image
- Image URL is automatically inserted into the homepage field