0

This question already has an answer here:

I am trying to add a link into the HTML head from (content/configuration/html) head section in the backend(admin) to a file that's located in my pub/static/version*****/frontend/ folder.

How can I link to this folder without using an absolute path?

Thanks

marked as duplicate by Amit Bera magento2 Sep 11 at 7:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

use Magento\Framework\View\Asset\Repository

 $asset = $this->assetRepository->createAsset('Magento_Catalog::images/image.png');
 $asset = $this->assetRepository->createAsset('My_Module::images/image.png');

app/design/frontend/VENDOR/THEME/

$asset = $this->assetRepository->createAsset('images/image.png');

use Magento\Framework\View\Asset\File

// Get the file url
$asset->getUrl();

// Get the file path
$asset->getFilePath();

// Get the content of the file
$asset->getContent();

Not the answer you're looking for? Browse other questions tagged or ask your own question.