All media endpoints are available since v2.2.0.
GET /media/overview
Returns aggregate statistics for the media library.Response
Total number of attachment posts in the database.
Total size of the uploads directory in bytes.
Human-readable uploads directory size (e.g.
128 MB).Number of attachment records whose physical files are missing on disk (sampled from up to 200 attachments).
Number of attachments not referenced by any post content or as a featured image (sampled from up to 500 attachments).
Number of groups of attachments that share the same MD5 hash (sampled from up to 300 attachments).
GET /media/orphaned
Returns attachment records whose physical files are missing from the uploads directory.Parameters
Maximum number of results to return. Defaults to
100, maximum 200.Number of results to skip for pagination. Defaults to
0.Response
Total number of orphaned attachments found.
DELETE /media/orphaned
Permanently deletes one or more orphaned attachments from the database.Parameters
Array of attachment post IDs to delete.
Response
Number of attachments successfully deleted.
IDs of attachments that could not be deleted.
GET /media/unused
Returns attachments that are not attached to any parent post, not used as a featured image, and whose filename does not appear in any published post content.Content scanning is approximate — it uses a
LIKE search on post_content. Attachments embedded via shortcode or block attributes with obfuscated URLs may not be detected as in use.Parameters
Maximum results to return. Defaults to
50, maximum 100.Number of results to skip. Defaults to
0.Response
Total number of unused attachments found.
DELETE /media/unused
Permanently deletes one or more unused attachments.Parameters
Array of attachment IDs to delete.
Response
Number of attachments deleted.
IDs of attachments that could not be deleted.
GET /media/duplicates
Groups attachments that share the same file content (MD5 hash). Returns groups with two or more files, sorted by wasted disk space descending.Parameters
Maximum number of attachments to scan. Defaults to
300, maximum 500.Response
Total number of duplicate groups found.
Total wasted bytes across all duplicate groups.
Human-readable total wasted size.
Number of attachments scanned.
DELETE /media/duplicate
Deletes a single duplicate attachment by ID.Parameters
The attachment ID to delete.
Response
Always
true on success.The ID of the deleted attachment.
GET /media/compress-candidates
Returns JPEG and PNG attachments with their file sizes so you can identify large images that may benefit from re-compression.Parameters
Maximum results to return. Defaults to
50, maximum 200.Number of results to skip for pagination. Defaults to
0.Response
Total number of JPEG and PNG attachments in the library.
POST /media/compress
Re-compresses a single JPEG or PNG attachment using the WordPress image editor. The file is overwritten in place.Parameters
The attachment ID to compress.
Compression quality from
1 to 100. Defaults to 82.Response
Always
true on success.The compressed attachment ID.
File size in bytes before compression.
File size in bytes after compression.
Human-readable size before.
Human-readable size after.
Bytes saved.
Human-readable bytes saved.
Percentage of file size saved.
