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.
Issue fork consumer_image_styles-3202870
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
Comment #3
bradjones1From a static analysis of the schema I think this is also missing a key for the
imageDerivativeskey betweenmetaandlinks?Comment #4
bradjones1Comment #5
bradjones1Sorry, 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_extrasfor this to be reflected in the Schemata schema.Comment #6
bradjones1Comment #7
bradjones1I was actually correct in #3 - this schema is missing the
imageDerivativeskey.Comment #8
bradjones1Comment #9
e0ipsoThis is now unblocked.
Comment #10
bradjones1Comment #11
e0ipsoI am merging this now. This might affect #3252023: Very slow JSON:API responses when images are stored on AWS bucket.
Comment #12
e0ipsoAfter a closer inspection, this needs to be rebased against 4.x.
Comment #13
e0ipsoChanging the base branch messes the MR integration in d.o. I will merge in GitLab, then.
Edit: I had to fix merge conflicts.