I'm trying to understand the media rest-API. The last item in the schema:
What is this? Missing vis-a-vi what exactly? Is this information used somehow by default?
Reference: developer.wordpress/rest-api/reference/media
I'm trying to understand the media rest-API. The last item in the schema:
What is this? Missing vis-a-vi what exactly? Is this information used somehow by default?
Reference: developer.wordpress/rest-api/reference/media
Share Improve this question asked Jun 9, 2020 at 22:07 John DeeJohn Dee 5135 silver badges14 bronze badges1 Answer
Reset to default 2Basically, it corresponds to missing thumbnails or custom-sized images in your media library.
And it's (by default) a private field in the REST API and the value is one or more image sizes as returned by wp_get_registered_image_subsizes()
.
And the function which is used with that field is wp_get_missing_image_subsizes()
which returns:
(array) An array of the image sub-sizes that are currently defined but don't exist for this image.
So for example, if you added a new image to your library and then — after the image's thumbnail and other custom sizes are generated — you programmatically called add_image_size()
, then you'd likely see the missing_image_sizes
field containing the newly added image size when you request the image data through the REST API. E.g.
Request URL: (GET method)
https://example/wp-json/wp/v2/media/123?context=edit&_wpnonce=<nonce>
Sample response for missing_image_sizes:
"missing_image_sizes":["my_size"]