How do I reference an image inside my custom module directory?
The \Drupal class has many useful static functions such as moduleHandler. I recommend (for future issues) to first search there, then in the core.services.yml &amp; system.services.yml files for a service or a method that could help.

\Drupal::moduleHandler()-&gt;getModule('foo')-&gt;getPath()