Interface MediaAPIs
- All Known Implementing Classes:
MediaApiClientModule
This interface provides methods for creating, retrieving,
and listing WpMedia resources.
Operations support standard WordPress REST API features such as pagination, filtering, sorting, and retrieval contexts.
Media operations typically involve handling binary file uploads together with metadata such as MIME type, filename, captions, descriptions, and attachment information.
Implementations are expected to communicate with the
/wp-json/wp/v2/media endpoint or compatible APIs.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new media item.delete(long id) Deletes a media item by its unique identifier.Retrieves a media item by its unique identifier using the given context.list(WpPagingQuery pageQuery, WpMediaQuery mediaQuery) Retrieves a paginated list of media items using optional filtering and sorting criteria.update(long id, WpMediaUpdateRequest updateRequest) Updates an existing media item.
-
Method Details
-
create
Creates a new media item.Uploads a media file to WordPress using the provided file content and metadata.
The uploaded file is sent to the WordPress media endpoint and results in the creation of a new
WpMediaattachment resource.- Parameters:
file- the file to upload; must not benullfileName- the filename to associate with the uploaded media item; must not benullmimeType- the MIME type of the uploaded file, for exampleimage/png; must not benull- Returns:
- the created
WpMedia
-
delete
Deletes a media item by its unique identifier.- Parameters:
id- the ID of the media item to delete- Returns:
- the media item deletion response
-
get
Retrieves a media item by its unique identifier using the given context.The context determines which fields are included in the response, for example
WpContext.VIEW,WpContext.EDIT, orWpContext.EMBED.- Parameters:
id- the ID of the media item to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis used- Returns:
- the matching
WpMedia
-
list
Retrieves a paginated list of media items using optional filtering and sorting criteria.The result set can be refined using
WpMediaQuery, for example by filtering on parent, search term, include or exclude lists, or sort order.- Parameters:
pageQuery- the pagination settings, including page number and page size; must not benullmediaQuery- additional media query parameters; may benullwhen no extra filtering is needed- Returns:
- a paginated response containing
WpMediaitems
-
update
Updates an existing media item.Updates a media item in WordPress using the provided request payload.
- Parameters:
id- the ID of the media item to updateupdateRequest- the category update request; must not benull- Returns:
- the updated
WpMedia
-