Media
ATUM extends the WordPress media endpoint (/wp-json/wp/v2/media) with an extra filter to get the images that are being used as featured images by a specific post type (for example, the product images).
You can identify the ATUM data with the corresponding labels.
This page only describes the ATUM additions. For the rest of properties, params and operations, please check the WordPress REST API handbook.
ATUM allows authenticating the requests to the /wp-json/wp/v2/media endpoint with the same WooCommerce API keys used for the rest of endpoints. The examples below use the WooCommerce client libraries set up with the wp/v2 version.
List all media items linked to a post type
This API helps you to view all the media items (attachments) that are set as the featured image of any post of the specified post type(s).
HTTP request
/wp-json/wp/v2/mediacurl "https://example.com/wp-json/wp/v2/media?linked_post_type=product&_fields=id,date,slug,title,media_type,mime_type,post,source_url" \
-u consumer_key:consumer_secret[
{
"id": 2468,
"date": "2018-10-15T10:37:24",
"slug": "hoodie-with-logo",
"title": {
"rendered": "hoodie-with-logo"
},
"media_type": "image",
"mime_type": "image/jpeg",
"post": 2211,
"source_url": "https://example.com/wp-content/uploads/2018/08/hoodie-with-logo.jpg"
},
{
"id": 2097,
"date": "2019-11-06T13:44:21",
"slug": "t_4_front",
"title": {
"rendered": "T_4_front"
},
"media_type": "image",
"mime_type": "image/jpeg",
"post": 2101,
"source_url": "https://example.com/wp-content/uploads/2019/11/T_4_front.jpg"
}
]Available parameters
| Parameter | Type | Description |
|---|---|---|
linked_post_type | string | Limit result set to attachments set as the featured image of any post of the given post type (e.g. product). Multiple post types can be passed separated by commas. The post types that aren't registered are ignored and, if none of them is valid, the result set is empty. ATUM |
If the user that owns the API keys can't read the private posts of a requested post type, only the images linked to published (public) posts of that post type are returned.