0

I want to get media url like abc.com/store/pub/media/ (site url like abc.com/store .) in My ko template(.html) file.

we can use require.toUrl(''); for static view file. same way i want to get media view file

0

I used a dirty code to get the media URL in any HTML file. You can use a better way if you want but this is a simple and dirty solution :)

Add following code to

app/design/frontend/vendor/theme/Magento_Theme/templates/html/absolute_footer.phtml

...
...

<script>
    window.getMediaUrl = "<?= $block->getBaseUrl() . 'pub/media/' ?>";
</script>

Now you can get media URL in any HTML file as given below

<span data-bind="text: window.getMediaUrl" ></span>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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