Problem with fetching translatable images

Created on 17 May 2024, 30 days ago
Updated 3 June 2024, 13 days 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.
🐛 Bug report
Status

Active

Version

10.2

Component
JSON API 

Last updated 1 day 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?

Production build 0.69.0 2024