wp media import <file>

Creates attachments from local files or URLs

Arguments

NameDescription
filePath to file or files to be imported. Supports the glob(3) capabilities of the current shell. If file is recognized as a URL (for example, with a scheme of http or ftp), the file will be downloaded to a temp file before being sideloaded

Options

NameDescription
--post_id <post_id>ID of the post to attach the imported files to
--title <title>Attachment title (post title field)
--caption <caption>Caption for attachent (post excerpt field)
--alt <alt_text>Alt text for image (saved as post meta)
--desc <description>'Description' field (post content) of attachment post
--skip-copyIf set, media files (local only) are imported to the library but not moved on disk. File names will not be run through wp_unique_filename() with this set
--preserve-filetimeUse the file modified time as the post published & modified dates. Remote files will always use the current time
--featured_imageIf set, set the imported image as the Featured Image of the post its attached to
--porcelainOutput just the new attachment ID