List Media
Retrieves all media files from the WordPress media library including images, videos, documents, and other attachments.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client Id - The client ID from the Connect node (optional if using direct credentials).
Options
- Site URL - (Optional) WordPress site URL. Use this if you want to authenticate directly without a Connect node.
- Credentials - (Optional) WordPress username and application password. Use this if you want to authenticate directly without a Connect node.
Output
- Media List - An array of all media objects from the WordPress media library.
How It Works
The List Media node retrieves all media items from WordPress using the WordPress REST API.
When executed, the node:
- Retrieves the authentication (either from Client Id or direct credentials)
- Sends a GET request to
/wp-json/wp/v2/mediaendpoint - Returns an array of all media objects with their complete metadata
Media Object Structure
Each media item in the returned Media List contains:
- id - Unique media ID
- date - Upload date
- date_gmt - Upload date in GMT
- modified - Last modified date
- slug - URL-friendly identifier
- status - Usually "inherit" for media
- type - Always "attachment" for media
- link - Public URL to the attachment page
- title - Media title object with rendered HTML
- author - Uploader user ID
- caption - Caption object
- alt_text - Alternative text for images
- mime_type - MIME type (image/jpeg, application/pdf, etc.)
- media_type - Category: image, video, audio, or file
- source_url - Direct URL to the media file
- media_details - Detailed metadata including:
- width - Image/video width in pixels
- height - Image/video height in pixels
- file - Relative file path
- filesize - File size in bytes
- sizes - Different image sizes (thumbnail, medium, large, etc.)
- image_meta - EXIF data for images
Authentication Methods
Method 1: Using Connect Node (Recommended)
Connect → Store Client Id → List Media (use Client Id)
Method 2: Direct Credentials
Provide both Site URL and Credentials directly in the node options.
Requirements
- A WordPress site with REST API enabled (WordPress 4.7+)
- No special permissions required for public media
- Authentication may be required for private or draft attachments
Error Handling
The node will return specific errors in the following cases:
- Authentication failure (if using credentials)
- Network connection errors
- WordPress REST API disabled
- Invalid response format
Usage Notes
- Returns all media items in the media library
- Includes images, videos, documents, and other file types
- Returns both used and unused media
- The source_url provides the direct link to download/view the file
- For images, multiple sizes are available in media_details.sizes
- Default WordPress pagination may apply (typically 100 items per page)
Example Output
Media List:
[
{
"id": 456,
"date": "2024-01-15T10:30:00",
"slug": "product-image",
"type": "attachment",
"link": "https://yoursite.com/product-image/",
"title": {
"rendered": "Product Image"
},
"author": 1,
"alt_text": "New product showcase",
"mime_type": "image/jpeg",
"media_type": "image",
"source_url": "https://yoursite.com/wp-content/uploads/2024/01/product.jpg",
"media_details": {
"width": 1920,
"height": 1080,
"file": "2024/01/product.jpg",
"filesize": 245678,
"sizes": {
"thumbnail": {
"file": "product-150x150.jpg",
"width": 150,
"height": 150,
"source_url": "https://yoursite.com/wp-content/uploads/2024/01/product-150x150.jpg"
},
"medium": {
"file": "product-300x169.jpg",
"width": 300,
"height": 169,
"source_url": "https://yoursite.com/wp-content/uploads/2024/01/product-300x169.jpg"
}
}
}
},
{
"id": 789,
"date": "2024-01-16T14:20:00",
"slug": "user-manual",
"type": "attachment",
"mime_type": "application/pdf",
"media_type": "file",
"source_url": "https://yoursite.com/wp-content/uploads/2024/01/manual.pdf",
"media_details": {
"filesize": 1024000,
"file": "2024/01/manual.pdf"
}
}
]
Common Use Cases
Media Audit
- List all media files in the library
- Check file types and sizes
- Identify unused media
- Analyze media storage usage
Media Management
- Export media metadata
- Backup media information
- Generate media inventory reports
- Track media uploads over time
Media Lookup
- Find media by filename or slug
- Get media URLs for embedding
- Retrieve media IDs for assignment
- Check if specific media exists
SEO Optimization
- Audit alt text for images
- Check missing metadata
- Identify images without descriptions
- Review file naming conventions
Media Migration
- Export media list for migration
- Compare media across environments
- Prepare media transfer operations
- Map media IDs between sites
Filtering and Processing Results
After retrieving the media list, you can process it using JavaScript or Filter nodes:
Filter by Media Type
const media = msg.media_list;
// Get only images
const images = media.filter(item => item.media_type === "image");
// Get only PDFs
const pdfs = media.filter(item => item.mime_type === "application/pdf");
// Get videos
const videos = media.filter(item => item.media_type === "video");
return { images, pdfs, videos };
Find Media by Filename
const media = msg.media_list;
const filename = "product-image";
const found = media.find(item => item.slug === filename);
return { media_item: found };
Get Media Uploaded in Date Range
const media = msg.media_list;
const startDate = new Date("2024-01-01");
const endDate = new Date("2024-01-31");
const filtered = media.filter(item => {
const uploadDate = new Date(item.date);
return uploadDate >= startDate && uploadDate <= endDate;
});
return { january_media: filtered };
Calculate Total Storage Used
const media = msg.media_list;
const totalBytes = media.reduce((sum, item) => {
const size = item.media_details?.filesize || 0;
return sum + size;
}, 0);
const totalMB = (totalBytes / (1024 * 1024)).toFixed(2);
return {
total_files: media.length,
total_storage_mb: totalMB
};
Find Images Missing Alt Text
const media = msg.media_list;
const missingAlt = media.filter(item =>
item.media_type === "image" && !item.alt_text
);
return {
images_without_alt: missingAlt,
count: missingAlt.length
};
Get Different Image Sizes
const media = msg.media_list;
const imageId = 456;
const image = media.find(item => item.id === imageId);
const sizes = image?.media_details?.sizes || {};
const sizeUrls = {
full: image.source_url,
thumbnail: sizes.thumbnail?.source_url,
medium: sizes.medium?.source_url,
large: sizes.large?.source_url
};
return { image_sizes: sizeUrls };
Example Workflows
Media Audit Report
1. List Media
2. Process results:
- Count by media type
- Calculate total storage
- Identify missing metadata
3. Generate CSV report
4. Send email with report
Find and Download Media
1. List Media
2. Filter by criteria (e.g., uploaded in last month)
3. For each media item:
- Download using source_url
- Save to local storage
4. Generate download log
Unused Media Cleanup
1. List Media
2. List Posts (get all post IDs)
3. For each media item:
- Check if used in any post
- If not used: Add to cleanup list
4. Review cleanup list
5. Delete unused media
Media SEO Optimization
1. List Media (filter images)
2. For each image without alt text:
- Generate alt text (AI or manual)
- Update media with alt text
3. Generate optimization report
Best Practices
- Cache the media list if using it multiple times
- Filter results to get only needed media types
- Handle large media libraries with pagination if needed
- Use source_url for direct file access
- Check media_type before processing media items
- Validate URLs before downloading
- Handle missing metadata gracefully
- Consider storage limits when analyzing media
Performance Considerations
- Large media libraries may take longer to retrieve
- Default WordPress pagination limits results (typically 100)
- Filter results in your flow to reduce processing time
- Cache results when making multiple queries
- For very large libraries, consider using pagination parameters
Media Types
Common media_type values:
- image - JPG, PNG, GIF, WebP, SVG
- video - MP4, MOV, AVI, WMV
- audio - MP3, WAV, OGG
- file - PDF, DOC, ZIP, and other documents
Common mime_type examples:
- image/jpeg - JPEG images
- image/png - PNG images
- application/pdf - PDF documents
- video/mp4 - MP4 videos
- audio/mpeg - MP3 audio
Troubleshooting
Empty Media List returned:
- Verify media exists in WordPress media library
- Check WordPress admin panel Media section
- Confirm REST API is enabled
- Check authentication if required
Missing media details:
- Some fields may be null for certain file types
- Check media_type to determine available fields
- Non-image files won't have image-specific metadata
URLs not accessible:
- Verify WordPress site URL is correct
- Check file permissions on server
- Ensure files weren't deleted from server
Image Sizes
WordPress generates multiple sizes for images:
- thumbnail - Usually 150x150px
- medium - Usually 300x300px
- medium_large - Usually 768px width
- large - Usually 1024px width
- full - Original size (use source_url)
Sizes depend on WordPress theme and settings.
Working with Media URLs
Direct Image URL
const imageUrl = media_item.source_url;
// Use in img tags, downloads, etc.
Thumbnail URL
const thumbUrl = media_item.media_details.sizes.thumbnail?.source_url;
Download Media
1. List Media → Get source_url
2. HTTP Request (GET source_url)
3. Save to file
Integration Examples
Export Media Inventory to CSV
1. List Media
2. Transform to CSV format:
- ID, Filename, Type, Size, Upload Date, URL
3. Write to CSV file
4. Upload to cloud storage or email
Backup Media Metadata
1. List Media
2. Save to JSON file
3. Include all metadata
4. Store for disaster recovery
Media Gallery Generation
1. List Media (filter by type: image)
2. Group by upload month
3. Generate HTML gallery
4. Create post with gallery
Broken Media Detection
1. List Media
2. For each media:
- Test source_url accessibility
- Record if 404 or error
3. Generate broken media report
4. Alert administrator