How can get path of image (src) in twig template of a module? 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:

&lt;img src="{{ directory }}/image/icons/my-image.svg" /&gt;


and below method:

MyModule.module

function MyModule_preprocess(&amp;$variables, $hook) {
    $variables['base_path'] = base_path();
}


and then in template:

&lt;img src="{{ base_path ~ directory }}image/icons/my-image.svg" /&gt;


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.
You need to use file_create_url much like Drupal 7 to transform a file path to file url. To get the path to the module, you should use drupal_get_path, combined it could look like this:

function my_module_preprocess(&amp;$variables, $hook) {
  $variables['img_path'] = file_create_url(drupal_get_path('module', 'my_module') . '/image/icons/my-image.svg');
}