How do we get the Image From the Asset path of the Extension

We can get the image in javascript using the below code.

This image has an empty alt attribute; its file name is image-90-1024x377.png
   showSampleImg: function () {
            var img = Utils.getAbsoluteUrl(
                getExtensionAssetsPath(
                    "Images/image001.png"
                )
            )
            console.log(img)
            var sample = `<div><img src="${img}"></div>`;
            var sampleImagePopup = new GlobalViewsMessageView({
                message: sample
            });

            this.application.getLayout().showInModal(sampleImagePopup, {
                closable: true,
                className: 'reorder-modal'
            });
        }

We can get the image of the extension asset using the getExtensionAssetsPath .the example added below.

<div class="row">
    <div class="col-xs-12 col-sm-12 col-md-6">
        <button data-action="add-to-inquiry" type="button" class="product-list-control-button-wishlist">
            {{ getExtensionAssetsPath "img/image.jpg"}}
        </button>
    </div>
</div>

Leave a comment

Your email address will not be published. Required fields are marked *