Image styles via JSON API or Consumers?

At the moment, retrieving various image styles for an uploaded image is difficult over a decoupled api: https://www.lullabot.com/articles/decoupled-drupal-hard-problems-image-styles

I think the leading effort is Consumer Image Styles: https://www.drupal.org/project/consumer_image_styles.

This module is built on Consumers, which lets you define an api response depending on the requesting application. You can define a collection of image styles to return only the necessary urls for the given app requesting them.

I would also consider building this around entity display modes. I thought it would be nice to select the image display in a display mode and have that url exposed to the api. This would work even better if it extended responsive images.

Consumer Image Styles needs to be updated to work with JSON API 2.x: https://www.drupal.org/project/consumer_image_styles/issues/3007268. Without this fixed, it's throwing major errors in the admin ui.

The other effort to track is: https://www.drupal.org/project/jsonapi_extras/issues/2868780. This will simply expose the urls through JSON API and hopefully let you configure some defaults.

I tried to build a Field Enhancer plugin for JSON API Extras, but it seems like these are not working for related entities, only field values.

Tags
JSON API