0

I was override Magento_Checkout/shipping-address/shipping-method-item static html file with Vendor_Module/checkout/shipping/shipping-method-item static html file.

now I wants to set static image URL in this shipping-method-item file. So, I put that static image at app/code/Vendor/Module/view/frontend/web/images/location.png.

then I mention code as like below in shipping-method-item file

<img data-bind="attr: { src: require.toUrl('Vendor_Module::images/location.png') }" alt="">

but it doesn't generate any path for image.

even I tried as like below

<img data-bind="attr: { src: require.toUrl('images/location.png') }" alt="">

then it generate path as like below

domain.com/static/version1663150096/frontend/Vendor_Name/Theme_Name/en_US/images/location.png

I doesn't have any idea about how to show image from my custom module path app/code/Vendor/Module/view/frontend/web/images/location.png

please help me...


Answer :-

Step 1 :- put image at /code/Vendor/Module/view/frontend/web/images/location.png location path

Step 2 :- write img tag code as like below in your static html file

<img data-bind="attr: { src: require.toUrl('Vendor_Module/images/location.png') }" alt="location-icon">

Anwser Given By:- @Bharath Kumar see here

1 Answer 1

1

to produce an image from the static files generated please follow the below sol:-

I have tried in my local development environment and have found a solution , the issue is with the image path actually , please check this browser screenshot as a proof that image can be shown

enter image description here

In your HTML file , you should call the image something like this:-

<img data-bind="attr:{src:require.toUrl('OX_PrintSampleContent/images/images.jpeg')}">

Please check this screenshot of the HTML code

enter image description here

This is the path where you should place your image in your module

app/code/vendor/module/view/frontend/web/images/images.jpeg

If this post has helped , please do like this helps me motivate me more to post such answers.Thanks and have a nice day.

3
  • Thanks you for helping me. now It's works. Sep 16, 2022 at 10:21
  • Very Glad , have a nice day. Sep 16, 2022 at 10:56
  • I need to complete the order without shipment createing for storepickup order type. I doesn't have any idea about how to achive this. can you help me for achive this problem? I need to achive this one from Magento Admin side & API also @Bharath Kumar J Sep 19, 2022 at 11:48

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.