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
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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
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>