Not all featured image sizes available in Rest API

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

Leave a Comment