0

I'm trying to understand the media rest-API. The last item in the schema:

missing_image_sizes

What is this? Missing vis-a-vi what exactly? Is this information used somehow by default?

Reference: developer.wordpress.org/rest-api/reference/media

1 Answer 1

2

Basically, 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.com/wp-json/wp/v2/media/123?context=edit&_wpnonce=<nonce>

  • Sample response for missing_image_sizes: "missing_image_sizes":["my_size"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.