Managing media

From ancoleman/ai-design-components · View interactive version

Managing media is an AI agent skill from the GitHub repository ancoleman/ai-design-components. Implements media and file management components including file upload (drag-drop, multi-file, resumable), image galleries (lightbox, carousel, masonry), video players (custom controls, captions, adaptive streaming), audio players (waveform, playlists), document viewers (PDF, Office), and optimizatio

How to use this skill

Skill file

Managing Media & Files

Purpose

This skill provides systematic patterns for implementing media and file management components across all formats (images, videos, audio, documents). It covers upload workflows, display patterns, player controls, optimization strategies, and accessibility requirements to ensure performant, accessible, and user-friendly media experiences.

When to Use

Activate this skill when:

Quick Decision Framework

Select implementation based on media type and requirements:

Images                  → Gallery pattern + lazy loading + responsive srcset
Videos                  → Player with controls + captions + adaptive streaming
Audio                   → Player with waveform + playlist support
Documents (PDF)         → Viewer with navigation + search + download
File Upload (<10MB)     → Basic drag-drop with preview
File Upload (>10MB)     → Chunked upload with progress + resume
Multiple Files          → Queue management + parallel uploads

For detailed selection criteria, reference references/implementation-guide.md.

File Upload Patterns

Basic Upload (<10MB)

For small files with simple requirements:

Example: examples/basic-upload.tsx

Advanced Upload (>10MB)

For large files requiring reliability:

Example: examples/chunked-upload.tsx

Image-Specific Upload

For image files with editing requirements:

Example: examples/image-upload-crop.tsx

Image Display Components

Image Gallery

For collections of images:

Example: examples/image-gallery.tsx

Carousel/Slider

For sequential image display:

Example: examples/carousel.tsx

Image Optimization

Essential optimization strategies:

Video Components

Video Player

For custom video playback:

Example: examples/video-player.tsx

Video Optimization

Performance strategies for video:

Audio Components

Audio Player

For audio playback:

Example: examples/audio-player.tsx

Document Viewers

PDF Viewer

For PDF document display:

Example: examples/pdf-viewer.tsx

Office Document Preview

For DOCX, XLSX, PPTX files:

Performance Optimization

File Size Guidelines

Validate client-side before upload:

Image Optimization Checklist

# Generate optimized image set
python scripts/optimize_images.py --input image.jpg --formats webp,jpg,avif

Strategies:

Reference references/performance-optimization.md for complete guide.

Video Optimization Checklist

Strategies:

Accessibility Requirements

Images

Essential patterns:

Videos

Essential patterns:

Audio

Essential patterns:

To validate accessibility:

node scripts/validate_media_accessibility.js

For complete requirements, reference references/accessibility-patterns.md.

Library Recommendations

Image Gallery: react-image-gallery

Best for feature-complete galleries:

npm install react-image-gallery

See examples/gallery-react-image.tsx for implementation.

Reference /xiaolin/react-image-gallery for documentation.

Alternative: LightGallery (more features, larger bundle)

Video: video.js

Best for custom video players:

npm install video.js

See examples/video-js-player.tsx for implementation.

Audio: wavesurfer.js

Best for waveform visualization:

npm install wavesurfer.js

See examples/audio-waveform.tsx for implementation.

PDF: react-pdf

Best for PDF rendering in React:

npm install react-pdf

See examples/pdf-react.tsx for implementation.

For detailed comparison, reference references/library-comparison.md.

Design Token Integration

All media components use the design-tokens skill for theming:

Supports light, dark, high-contrast, and custom themes.

Reference the design-tokens skill for theme switching.

Example token usage:

.upload-zone {
  border: var(--upload-zone-border);
  background: var(--upload-zone-bg);
  padding: var(--upload-zone-padding);
  border-radius: var(--upload-zone-border-radius);
}

.image-gallery {
  gap: var(--gallery-gap);
}

.video-player {
  background: var(--video-player-bg);
  border-radius: var(--video-border-radius);
}

Responsive Strategies

Image Galleries

Four responsive approaches:

  1. Grid layout - CSS Grid with auto-fit columns
  2. Masonry layout - Pinterest-style with variable heights
  3. Carousel - Single image on mobile, multiple on desktop
  4. Stack - Vertical list on mobile, grid on desktop

See examples/responsive-gallery.tsx for implementations.

Video Players

Responsive considerations:

Reference references/responsive-media.md for patterns.

Cloud Storage Integration

Client-Side Direct Upload

For AWS S3, Cloudinary, etc.:

  1. Request signed URL from backend
  2. Upload directly to cloud storage
  3. Notify backend of completion
  4. Display uploaded media

Benefits:

See examples/s3-direct-upload.tsx for implementation.

Reference references/cloud-storage.md for setup.

Testing Tools

Generate mock media:

# Generate test images
python scripts/generate_mock_images.py --count 50 --sizes thumb,medium,large

# Generate test video metadata
python scripts/generate_video_metadata.py --duration 300

Validate media accessibility:

node scripts/validate_media_accessibility.js

Analyze performance:

node scripts/analyze_media_performance.js --files images/*.jpg

Working Examples

Start with the example matching the requirements:

basic-upload.tsx              # Simple drag-drop upload
chunked-upload.tsx            # Large file upload with resume
image-upload-crop.tsx         # Image upload with cropping
image-gallery.tsx             # Grid gallery with lightbox
carousel.tsx                  # Image carousel/slider
video-player.tsx              # Custom video player
audio-player.tsx              # Audio player with controls
audio-waveform.tsx            # Audio with waveform visualization
pdf-viewer.tsx                # PDF document viewer
s3-direct-upload.tsx          # Direct upload to S3
responsive-gallery.tsx        # Responsive image gallery patterns

Resources

Scripts (Token-Free Execution)

References (Detailed Documentation)

Examples (Implementation Code)

Assets (Templates and Configs)

Cross-Skill Integration

This skill works with other component skills:

Next Steps

  1. Identify the media type (images, video, audio, documents)
  2. Determine upload requirements (size, quantity, editing)
  3. Choose display pattern (gallery, carousel, player, viewer)
  4. Select library or implement custom solution
  5. Implement accessibility requirements
  6. Apply optimization strategies
  7. Test performance and responsive behavior
  8. Integrate with cloud storage (optional)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.