Problem with fetching translatable images

Created on 17 May 2024, 7 months ago
Updated 3 July 2024, 6 months ago

Problem/Motivation

Hi, I have a problem with fetching translatable images via JSON:API. I use default article node type, there I have a field allowing to upload images, but this field is translatable, so you can upload different image and set different alternative text per language.

I cannot fetch images via JSON:API when I'm using image from the default translation and this translation is unpublished.

Steps to reproduce

  1. Add a translatable image field to node article.
  2. Add an article in two translations (i.e. English and Italian).
  3. Make EN translation the default / original one.
  4. For EN translation upload image and don't do it for the IT translation (let Drupal use default one, from EN translation).
  5. Unpublish EN translation and publish IT translation.
  6. Go to /it/jsonapi/node/article/{uuid}.
  7. You should see under meta.omitted that it wasn't possible to get image (error saying Some resources have been omitted because of insufficient authorization). If you publish EN translation, this error should disappear and you should get image normally.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
JSON API 

Last updated 6 days ago

Created by

🇵🇱Poland tivi22

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tivi22
  • 🇳🇱Netherlands bbrala Netherlands
  • 🇮🇹Italy Bladedu Italy

    Although I'm not sure if it's 100% related, since 10.2.x I'm encountering a similar issue with a translatable image field.

    After some debugging I found what could be the problem. Basically while the route enhancer is invoking all of them, the query parameter `resourceVersion` that would trigger the `getRelated` method on the jsonapi controller is failing to propagate the active language on the entity.

    Would you care trying my patch and see if that resolves your issue as well?

  • 🇳🇿New Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies. Also, 10.2 is in security mode now.

Production build 0.71.5 2024