Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

JSON:API Image Styles

Security covered Drupal 9–11
View on drupal.org

πŸ‡ΊπŸ‡¦

This module is maintained by Ukrainian developers.
Please consider supporting Ukraine in a fight for their freedom and safety of Europe.

Overview

JSON:API Image Styles is a JSON:API extension that exposes image style urls of a Drupal image to jsonapi export. This allows e.g. crop-defined image styles to be consumed by frontend builds.

Usage

By default all image styles are exposed to the file entity attributes in JSON:API output. For controlling exposed image styles the module provides a configuration option /admin/config/services/jsonapi/image_styles to expose only selected styles.

Version 3.x

Version 3.x of this module is recommended for Drupal 9 and the minimum PHP version required is PHP 7.4. Unfortunately this cannot be enforced by the module composer.json because Drupal 9.x core enforces a PHP 7.3 minimum in CI.

The following is an example of data added to the attributes of an image file object in a JSON:API response:

"image_style_uri": {
  "large": "[...]/styles/large/public/2021-09/headshot-2048.jpg?itok=fXgx7-bT",
  "medium": "[...]/styles/medium/public/2021-09/headshot-2048.jpg?itok=zwwMSGsi",
  "thumbnail": "[...]/styles/thumbnail/public/2021-09/headshot-2048.jpg?itok=eMUH72Al",
  "wide": "[...]/styles/wide/public/2021-09/headshot-2048.jpg?itok=FDUaWhH0"
}

Version 2.x

Version 2.x of this module supports Drupal 8 and PHP 7.3. Version 3.x is recommended for Drupal 8 users. Support for 2.x will end with the Drupal 8 EOL on 2 November 2021 (see PSA-2021-2021-06-29). After that date only security updates will be considered for 2.x.

Data added to JSON:API responses by 2.x differs from 3.x. The following is an example of data added to the attributes of an image file object in a JSON:API response:

"image_style_uri": [
  {
    "large": "[...]/styles/large/public/2021-09/headshot-2048.jpg?itok=fXgx7-bT"
  },
  {
    "thumbnail": "[...]/styles/thumbnail/public/2021-09/headshot-2048.jpg?itok=eMUH72Al"
  },
  {
    "wide": "[...]/styles/wide/public/2021-09/headshot-2048.jpg?itok=FDUaWhH0"
  },
  {
    "medium": "[...]/styles/medium/public/2021-09/headshot-2048.jpg?itok=zwwMSGsi"
  }
]

Similar module

Consumer Image Styles provides similar functionality but with more complex setup, configurations and dependencies.

Depends on

Dependencies of the latest stable release

  • image Drupal core
  • jsonapi Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Aug 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
3.0.2 Stable 9–11 Sep 24, 2024
3.0.1 Stable Aug 10, 2024