Overview
Media management is integrated into multiple custom post types:- Services: Images, video files, and video URLs
- Courses: Image galleries with attachment IDs
- About Us: Main images and videos with statistics
Media Types Supported
Images
- WordPress Media Library integration
- Direct URL storage or attachment ID storage
- Thumbnail previews in admin
- Multiple images per post
- Drag-and-drop upload support
Video Files
- Upload directly to WordPress Media Library
- Support for MP4, WebM, and other formats
- Stored as media library URLs
- Server bandwidth considerations
Video URLs
- External video hosting (YouTube, Vimeo)
- oEmbed automatic embedding
- No server storage required
- Unlimited video linking
Services Multimedia System
Implementation
The services multimedia meta box (inc/cpts/services.php:62-180):
JavaScript Media Upload
Saving Media Data
Courses Media System
Image Gallery with Attachment IDs
Courses store attachment IDs instead of URLs for better integration:JavaScript for Attachment IDs
Saving Attachment IDs
About Us Media System
Custom Meta Fields
The About Us page supports custom media fields (inc/utils.php:49-71):
Admin Assets for Media Upload
Displaying Media on Frontend
Display Images
Display Videos
Responsive Image Gallery
Media Optimization Best Practices
Image Optimization
- Compress Before Upload: Use tools like TinyPNG or ImageOptim
- Appropriate Dimensions: Don’t upload 4000px images for 800px displays
- Format Selection:
- JPEG for photos
- PNG for graphics with transparency
- WebP for modern browsers (with fallback)
- Use WordPress Image Sizes: Leverage thumbnail, medium, large sizes
- Lazy Loading: Implement lazy loading for galleries
Video Strategy
-
External Hosting Preferred:
- Use YouTube/Vimeo for long videos
- Reduces server bandwidth and storage
- Better streaming performance
- Free CDN delivery
-
When to Upload Videos:
- Short clips (< 30 seconds)
- Background videos
- No need for player controls
- Private/unlisted content
-
Video Compression:
- Use H.264 codec for compatibility
- Target 720p or 1080p maximum
- Compress with HandBrake or similar
- Keep file size under 10MB when possible
Server Considerations
Security Considerations
File Type Validation
URL Sanitization
All media URLs are sanitized:Troubleshooting
Media Library Not Opening
Ensurewp_enqueue_media() is called:
Upload Size Limits
Increase limits in.htaccess:
Video Not Embedding
Check oEmbed provider support:Workflow Example
- Create a new service
- Add 5 optimized images (compressed JPEGs, 1200px wide)
- Add 1 YouTube URL for promotional video
- Add 1 uploaded video file (15-second clip, 5MB)
- Verify all media displays correctly in admin
- Preview on frontend to check responsive behavior
- Test video playback on mobile devices
- Publish and monitor page load time

