Skip to content

SVG Icons

Uploads an SVG (from a URL or raw markup) into the WordPress Media Library so it can be referenced by Elementor’s icon and icon-box widgets.

Input: one of:

  • url: external SVG URL to download
  • markup: raw SVG markup as a string

Plus:

  • title: optional, defaults to filename or "Custom SVG"

Returns: { attachment_id, url, library_id }.

The library_id is the value to pass into a widget’s icon setting:

{
"icon": {
"value": { "id": 1234, "url": "https://example.com/icon.svg" },
"library": "svg"
}
}

add-icon and add-icon-box accept either a Font Awesome icon name or an SVG library ID: same control type, the widget figures out which.

Capability: edit_posts + ownership check on the calling user.

WordPress doesn’t allow SVG uploads through the normal Media Library by default (XSS risk via embedded <script> tags). EMCP Tools sanitizes SVG markup before saving (strips <script>, on* event attributes, and any external references) using the same allow-list approach as the WP-SVG-Sanitizer library.

If you need to upload a complex SVG that includes legitimate filter definitions or gradients, those pass through. Only execution vectors get stripped.

The fastest way to populate an Elementor icon set is to use a system like Lucide or Heroicons. They expose raw SVG markup for every icon. Ask the AI to pull a specific icon’s SVG, then call upload-svg-icon with the markup, then reference the returned ID in an icon widget.