I've got default images located in a custom module directory and I'd like to load them using
hook_preprocess_node(). I then will pass the images to the template file.
In the screenshot, I'm loading an image into
$default_image, which renders correctly when passed to the template file.
Instead of loading the image from an entity field, I want to read the image directly from the directory in the custom module. Clearly, the path I manually built into
$premier_tech_image is incorrect.
The problem is NOT how to access the file. For example, we use code like this for JSON feeds.
$module_handler = $this->moduleHandler; $module_path = $module_handler->getModule('my_custom_module')->getPath(); $resource = $module_path . '/resources/countries.json';
How do I correctly pass the reference to an image located in the directory of a custom module to the template file?