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

Not all featured image sizes available in Rest API

programmeradmin0浏览0评论

I'm using Vue.js to consume the Rest API for both posts and a custom post type. I'm using the _embed query on the URL for the endpoint to get sizes for the each featured image.

The issue that I'm encountering is that the "full" size is present on most featured images, but not all. As an experiment, I've also registered a custom image size, which also shows on most posts but not all. I've regenerated media via WP CLI, but no success.

This is troublesome because it causes unpredictability in the Vue app if the size isn't present for a particular post (and, yes, I know I should write the logic to fail gracefully for that, but it feels like this should be a safe bet that each image would have the "out of the box" featured image sizes).

When calling my endpoint into Postman, I can see that _embedded['wp:featuredmedia'][0].media_details.sizes varies for each item. Only some have "large," some have "medium_large", etc. I've used wp media regenerate, which returns success, but still doesn't resolve.

So my question is, how do I ensure that all items of this post type have the same featured image sizes available?

发布评论

评论列表(0)

  1. 暂无评论