Problem/Motivation

The ImageStyles enhancer provides a schema for its transformed output which is a bit too strict regarding to meta properties it doesn't directly manage.

The width and height properties are typed as int only instead of only or null, which mandates their presence. In the Drupal wilderness though you may occasionally encounter image field data which does not have these properties set.

While it's cleary debatable if the situation should arise or not, the absence of width & height doesn't prevent styles URL to be provided. On top on that, it should be this module concerns to check this data validity as it does not manage it.

Steps to reproduce

Through JSON:API, try to access an entity that has an Image field which doesn't have width & height value while having the ImageStyles field enhancer enabled. It results in an Exception/5xx error

Proposed resolution

Allow width & height to be null in the transformed output.

Remaining tasks

Review the proposed solution.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

garphy created an issue. See original summary.

bradjones1’s picture

From a static analysis of the schema I think this is also missing a key for the imageDerivatives key between meta and links?

bradjones1’s picture

Status: Active » Needs work
bradjones1’s picture

Sorry, I was confused - this is correct for the top level; my note regarding image derivatives is dependent on #3069385: Provide derivative image dimensions (width/height) alongside URL and I think if that issue drops, this one can be updated easy enough.

Honestly though I'm curious how this is working at all; I had to apply #3224754: Make schema normalizer overrides module-agnostic (support jsonapi_schema as well as Schemata/OpenAPI) to jsonapi_extras for this to be reflected in the Schemata schema.

bradjones1’s picture

Title: Relax schema of the enhancer output for height and width properties » [PP-1] Relax schema of the enhancer output for height and width properties
Status: Needs work » Postponed
bradjones1’s picture

Status: Postponed » Needs work

I was actually correct in #3 - this schema is missing the imageDerivatives key.

bradjones1’s picture

Title: [PP-1] Relax schema of the enhancer output for height and width properties » [PP-1] Fix JSON schema for image style enhancer
e0ipso’s picture

Title: [PP-1] Fix JSON schema for image style enhancer » Fix JSON schema for image style enhancer

This is now unblocked.

bradjones1’s picture

Status: Needs work » Needs review
e0ipso’s picture

Status: Needs review » Fixed
e0ipso’s picture

Version: 8.x-3.x-dev » 4.x-dev
Status: Fixed » Needs work

After a closer inspection, this needs to be rebased against 4.x.

e0ipso’s picture

Status: Needs work » Fixed

Changing the base branch messes the MR integration in d.o. I will merge in GitLab, then.

Edit: I had to fix merge conflicts.

  • e0ipso committed b484f42 on 4.x authored by garphy
    Issue #3202870 by bradjones1, garphy, e0ipso: Fix JSON schema for image...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.