How can I get access to image path (source/url) in twig template of a module?
I try to render an image that's located in my module folder in module template, this image is a static image that's not assigned to a field.
I try several methods to achieve this demands for eg:
<img src="{{ directory }}/image/icons/my-image.svg" />
and below method:
MyModule.module
function MyModule_preprocess(&$variables, $hook) {
$variables['base_path'] = base_path();
}
and then in template:
<img src="{{ base_path ~ directory }}image/icons/my-image.svg" />
And i try solution that's written in this article too: Using images in custom module
But both of them refer to my theme directory instead of module directory and seems none of them work in module template.
Thanks for any solution.