Skip to content

🐛 [Bug]: Image data is overridden when inlineAssets is true #328

@leifmarcus

Description

@leifmarcus

Package

storyblok-js-client (Client SDK)

Bug Description

When using the storyblok-js-client SDK and setting the option inlineAssets to true, all information of the current image is overridden. This is problematic, when for instance the alt text is different on the image, that is used in the story.

If you look into the implementation, you see, that the whole image object is replaced with the master asset object, which might have different fields, then the image, that is used in the story.

Steps to Reproduce

  1. create a Story in Storyblok that has an image included
  2. select an image from the Asset Library
  3. override the alt text of the image in the story
  4. request the story using the storyblok-js-client with inlineAssets: true.
  5. See the alt text from the master image instead of the change alt text

Expected Behavior

when inlining assets, only properties, that are not present on the image attached to the story should be merged. For instance, the is_private property is not present on the attached image. Asset fields like the alt text or the caption should not be overridden.

Actual Behavior

Currently, due to the complete override of the image, all information that is changed on the attached image will be overridden from the master image which leads to not translated alt text or captions.

Code Sample

// how it is currently done in your code
if (processedNode.fieldtype === 'asset' && Array.isArray(response.data.assets)) {
  // Replace the assets array with the actual asset objects
  processedNode = {
    ...processedNode,
    // this will completely override all root level fields of the attached asset.
    ...response.data.assets.find((asset: any) => asset.id === processedNode.id),
  };
}

Environment

System:
    OS: macOS 26.0
    CPU: (14) arm64 Apple M4 Pro
    Memory: 1.12 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.19.0 - ~/.nvm/versions/node/v22.19.0/bin/node
    npm: 10.9.3 - ~/.nvm/versions/node/v22.19.0/bin/npm
    pnpm: 10.16.1 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 140.0.7339.186
    Edge: 140.0.3485.81
    Safari: 26.0
  npmPackages:
    @storyblok/astro: ^7.2.5 => 7.3.0 
    @storyblok/richtext: ^3.7.0 => 3.8.0 
    storyblok: ^4.4.1 => 4.6.2 
    vue: ^3.5.21 => 3.5.21

Error Logs

Additional Context

No response

Metadata

Metadata

Assignees

Labels

dx[General] Improvement or fix with impact on the developer experience.pending-triage[Status] Ticket is pending to be prioritised

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions