最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

uploads - In the media Rest API, what is "missing_image_sizes"?

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 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/wp-json/wp/v2/media/123?context=edit&_wpnonce=<nonce>

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

发布评论

评论列表(0)

  1. 暂无评论