WordPress: Add image
wp_add_imageAdd an image from a URL to the site's media library. Nothing is overwritten: the file is a new library item, invisible to visitors until used, and existing media stays as it was. With set_featured it also becomes that post's featured image, which REPLACES the one visitors currently see — so that case returns a preview and needs confirm: true; the previous image remains in the library and can be set back. Always set alt text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alt | Yes | Describe the image for screen readers and search engines | |
| url | Yes | ||
| site | Yes | ||
| confirm | No | Needed only when set_featured is true, since that changes a live post. Leave false to preview; set true only after the user has agreed. | |
| filename | No | ||
| attach_to | No | ||
| set_featured | No |