I have a file called image.png
Folder structure:
-app
-code
-Roland
-HelloWorld
-view
-adminhtml
-web
-frontend
-web
-image.png
When I call this on frontend:
$this->getViewFileUrl("Roland_HelloWorld::image.png");
Result: http://localhost/magento2/pub/static/frontend/Magento/luma/en_US/Roland_HelloWorld/image.png
And the image loads fine.
When I call this on backend:
$this->getViewFileUrl("Roland_HelloWorld::image.png");
Result: http://localhost/magento2/pub/static/adminhtml/Magento/backend/en_US/Roland_HelloWorld/image.png
The image is not loading as it is not in the adminhtml/web/ folder.
Is there any way to load the static url for this asset with the frontend application area? What would be the official way, I do not want to duplicate this image into both folder?
UPDATE #1
This might be good, does anyone know better solution?
echo $this->getViewFileUrl("Roland_HelloWorld::image.png", array(
'area' => 'frontend',
'theme' => 'Magento/Luma'
));