Skip to main content
All media endpoints are available since v2.2.0.

GET /media/overview

Returns aggregate statistics for the media library.
curl -X GET https://example.com/wp-json/wp-manager-pro/v1/media/overview \
  -H "X-WP-Nonce: YOUR_NONCE"

Response

total_attachments
integer
Total number of attachment posts in the database.
total_size
integer
Total size of the uploads directory in bytes.
total_size_human
string
Human-readable uploads directory size (e.g. 128 MB).
orphaned_count
integer
Number of attachment records whose physical files are missing on disk (sampled from up to 200 attachments).
unused_count
integer
Number of attachments not referenced by any post content or as a featured image (sampled from up to 500 attachments).
duplicate_groups
integer
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.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/media/orphaned?limit=50&offset=0" \
  -H "X-WP-Nonce: YOUR_NONCE"

Parameters

limit
integer
Maximum number of results to return. Defaults to 100, maximum 200.
offset
integer
Number of results to skip for pagination. Defaults to 0.

Response

total
integer
Total number of orphaned attachments found.
items
array

DELETE /media/orphaned

Permanently deletes one or more orphaned attachments from the database.
Deleted attachment records cannot be recovered. Ensure you have a backup before bulk deleting.
curl -X DELETE https://example.com/wp-json/wp-manager-pro/v1/media/orphaned \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"ids": [42, 57, 103]}'

Parameters

ids
array
required
Array of attachment post IDs to delete.

Response

deleted
integer
Number of attachments successfully deleted.
errors
array
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.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/media/unused?limit=50&offset=0" \
  -H "X-WP-Nonce: YOUR_NONCE"

Parameters

limit
integer
Maximum results to return. Defaults to 50, maximum 100.
offset
integer
Number of results to skip. Defaults to 0.

Response

total
integer
Total number of unused attachments found.
items
array

DELETE /media/unused

Permanently deletes one or more unused attachments.
This permanently deletes the attachment records and their associated files. Verify the list before deleting.
curl -X DELETE https://example.com/wp-json/wp-manager-pro/v1/media/unused \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"ids": [88, 91]}'

Parameters

ids
array
required
Array of attachment IDs to delete.

Response

deleted
integer
Number of attachments deleted.
errors
array
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.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/media/duplicates?scan_limit=300" \
  -H "X-WP-Nonce: YOUR_NONCE"

Parameters

scan_limit
integer
Maximum number of attachments to scan. Defaults to 300, maximum 500.

Response

groups
array
total_groups
integer
Total number of duplicate groups found.
total_wasted
integer
Total wasted bytes across all duplicate groups.
total_wasted_human
string
Human-readable total wasted size.
scanned
integer
Number of attachments scanned.

DELETE /media/duplicate

Deletes a single duplicate attachment by ID.
The attachment and its associated files are permanently deleted. Keep the attachment with the lowest ID (oldest) to preserve the original.
curl -X DELETE https://example.com/wp-json/wp-manager-pro/v1/media/duplicate \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"id": 77}'

Parameters

id
integer
required
The attachment ID to delete.

Response

success
boolean
Always true on success.
deleted_id
integer
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.
curl -X GET "https://example.com/wp-json/wp-manager-pro/v1/media/compress-candidates?limit=50" \
  -H "X-WP-Nonce: YOUR_NONCE"

Parameters

limit
integer
Maximum results to return. Defaults to 50, maximum 200.
offset
integer
Number of results to skip for pagination. Defaults to 0.

Response

total
integer
Total number of JPEG and PNG attachments in the library.
items
array

POST /media/compress

Re-compresses a single JPEG or PNG attachment using the WordPress image editor. The file is overwritten in place.
curl -X POST https://example.com/wp-json/wp-manager-pro/v1/media/compress \
  -H "X-WP-Nonce: YOUR_NONCE" \
  -H "Content-Type: application/json" \
  -d '{"id": 42, "quality": 80}'

Parameters

id
integer
required
The attachment ID to compress.
quality
integer
Compression quality from 1 to 100. Defaults to 82.

Response

success
boolean
Always true on success.
id
integer
The compressed attachment ID.
before_size
integer
File size in bytes before compression.
after_size
integer
File size in bytes after compression.
before_size_human
string
Human-readable size before.
after_size_human
string
Human-readable size after.
saved
integer
Bytes saved.
saved_human
string
Human-readable bytes saved.
saved_pct
number
Percentage of file size saved.

Build docs developers (and LLMs) love