How to get gallery images in knockoutjs in Magento2.3.0?

Any help would be appreciated.

  • can you please add more details about this Jan 10, 2020 at 10:37
  • I have customized my product variant images in frontend for multiple image upload, so while edit I need to get the gallery images. as the js is written in knockoutjs. So I am not able to get the gallery images. I am unaware of knockoutjs.
    – Amy
    Jan 10, 2020 at 10:46

1 Answer 1


You need to pass it to your component via the PHTML file, add this to your PHTML file:

<script type="text/x-magento-init">
        ".yourSelector": {
            "yourComponentAliasORPath": {
                "galleryImagesJson": <?= /* @noEscape */ $block->getGalleryImagesJson() ?>,

Then in your JS you can access it with this.config.galleryImagesJson.

  • Hi, the link you shared are showing 404 error.
    – Amy
    Jan 10, 2020 at 11:43
  • Ah sorry I forgot those components haven't been open sourced yet, it works in the same way I mentioned above. You pass the data through to the JS within the text/x-magento-init tag and then in your JS you access it from this.config
    – Ben Crook
    Jan 10, 2020 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.