REST APIeasy-svg/v1/library/media

easy-svg/v1/library/media

Turns SVGs already in the media library into icons, up to 25 per request.

REST endpoint · Easy SVG · Status: Internal · Defined in includes/panel.php

Internal: not part of the promised public surface. It may change without notice.

Usage

POST /wp-json/easy-svg/v1/library/media

Example

curl -X POST https://example.com/wp-json/easy-svg/v1/library/media \
	-H 'Content-Type: application/json' \
	-H 'X-WP-Nonce: <nonce>' \
	-d '{"ids":[101,102]}'

Description

Takes attachment ids, never bytes, and reads each file from disk so offloaded media is reported as no_file instead of failing on CORS. Every file goes through the same sanitizer and bounds as an upload, with the attachment title as label. Answers 400 easy_svg_no_ids for an empty list and 400 easy_svg_too_many above 25; per-file results are in report.

Permission: manage_options (easy_svg_panel_rest_permission)

Parameters

body
idsinteger[]
Required

Attachment ids of SVGs, 1 to 25.

Response

The library payload plus report: one entry per id with id, label, state, message, and slug and wanted when added.

{
  "items": [
    {
      "id": 42,
      "slug": "heart",
      "label": "Heart",
      "content": "<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21l-8-8a5 5 0 0 1 8-6 5 5 0 0 1 8 6z"/></svg>"
    }
  ],
  "total": 1,
  "truncated": false,
  "report": [
    {
      "id": 101,
      "label": "heart",
      "state": "added",
      "message": "Icon added.",
      "slug": "heart",
      "wanted": "heart"
    },
    {
      "id": 102,
      "label": "photo",
      "state": "not_svg",
      "message": "That is not an SVG the sanitizer accepts."
    }
  ]
}
The handler reads the JSON body only; send Content-Type: application/json. Values in the query string are ignored by the handler.