Images in Plugin with Twig-View or PHP-View

Hello guys,
I am a beginner in Mautic plugin development. Currently, I try to create a simple plugin, which adds a menu item and display a view.
It is working fine but I came across a ambiguity with twig and php view templates.
I try to show a view in Mautic with an images. I put the image in the Asset/images directory of the plugin. Now I see, that I have two posibilities to create a view:

  • myView.html.php
  • myView.html.twig

As I see in the other Mautic files, everyone uses twig. But I have no clue how to show an image in a twig template because the url for the image is never correct, no matter what I tried. Hence I tried with the myView.html.php:

If I read the documentation, the $view variable is available in myView.html.php from which I would get the image path and url.

echo '<img src="' . $view['assets']->getUrl('plugins/HelloWorldBundle/assets/images/earth.png') . '" />';

Unfortunately, if i try to use php-views, it simply does not show anything if I call myView.html.php from the delegateView-Method and if I try a twig template I do net get the correct path (url) for the image.

Can someone explain or just give me the code for displaying an image in a twig template?

It’s Mautic4?