WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

XML-RPC WordPress API/Media

wp.getMediaItem

Retrieve a media item (i.e, attachment).

Added in WordPress 3.1.

Parameters

  • int blog_id
  • string username
  • string password
  • int attachment_id

Return Values

  • struct
    • string attachment_id (Added in WordPress 3.4)
    • datetime date_created_gmt
    • int parent: ID of the parent post.
    • string link
    • string title
    • string caption
    • string description
    • MediaItemMetadata metadata
    • PostThumbnailImageMeta image_meta
    • string thumbnail

MediaItemMetadata

  • struct
    • int width
    • int height
    • string file
    • struct sizes
      • MediaItemSize thumbnail
      • MediaItemSize medium
      • MediaItemSize large

MediaItemSize

  • struct
    • string file
    • string width
    • string height
    • string mime-type : image/jpeg or ...

PostThumbnailImageMeta

  • struct
    • int aperture
    • string credit
    • string camera
    • string caption
    • int created_timestamp
    • string copyright
    • int focal_length
    • int iso
    • int shutter_speed
    • string title

Errors

  • 403
  • 404
    • If no attachment with that attachment_id exists.

wp.getMediaLibrary

Retrieve list of media items.

Added in WordPress 3.1.

Parameters

  • int blog_id
  • string username
  • string password
  • struct filter: Optional (and all members are optional).
    • int number: Total number of media items to retrieve.
    • int offset
    • int parent_id: Limit to attachments on this post ID. 0 shows unattached media items. Empty string shows all media items.
    • string mime_type

Return Values

Errors

wp.uploadFile

Upload a media file.

Parameters

  • int blogid
  • string username
  • string password
  • struct data
    • string name: Filename.
    • string type: File MIME type.
    • string bits: binary data. Shouldn't be base64-encoded.
    • bool overwrite: Optional. Overwrite an existing attachment of the same name. (Added in WordPress 2.2)

Return Values

  • struct
    • string id (Added in WordPress 3.4)
    • string file: Filename.
    • string url
    • string type

Errors

  • 401
  • 500
    • File upload failure.