REST APIeasy-svg-pro/v1/audit/clean

easy-svg-pro/v1/audit/clean

Cleans one SVG attachment in place after storing its original.

REST endpoint · Easy SVG Pro · Status: Internal · Defined in includes/core/rest.php

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

Usage

POST /wp-json/easy-svg-pro/v1/audit/clean

Example

curl -u admin:app-password -H 'Content-Type: application/json' -d '{"attachment":101}' https://example.com/wp-json/easy-svg-pro/v1/audit/clean

Description

The attachment must be image/svg+xml and its file must resolve inside the uploads folder, otherwise 400 easy_svg_pro_not_svg or easy_svg_pro_outside_uploads. The untouched bytes are stored with the attachment and read back before the file is rewritten; if that fails nothing is written and the state is backup_failed. Only the first original is ever kept. A cleaned or already clean file leaves the stored report. Permission: Requires manage_options, an active licence and the audit feature (SVG cleaner) switched on.

Permission: Requires manage_options, an active licence and the audit feature (SVG cleaner) switched on.

Parameters

body
attachmentinteger
Required

The attachment id to clean, at least 1.

Return value

returnWP_REST_Response|WP_Error

state: cleaned (with removed_tags and removed_attributes), already_clean, refused_malformed, refused_too_large, unreadable, backup_failed or write_failed.

Response

state: cleaned (with removed_tags and removed_attributes), already_clean, refused_malformed, refused_too_large, unreadable, backup_failed or write_failed.

{
  "state": "cleaned",
  "removed_tags": [
    "script"
  ],
  "removed_attributes": [
    "onload"
  ]
}
Cleaning rewrites the file in uploads. Sanitizing is lossy on purpose, so animations or scripts a designer relied on are gone; the kept original is the way back.