In my controller, I implemented a function to publish a single asset, such as an image, and returned the URL:
public function publishAsset( $src ) {
$path = Yii::getAlias( $src );
if ( ! $this->assetManager ) {
$this->assetManager = new AssetManager();
}
$return = $this->assetManager->publish( $path );
return $return[1];
}
And then call it in my view as follows:
<?= $this->context->publishAsset('@app/assets/img/logo.png') ?>
Works fine, but the function returns the published URL without the "scheme" in front of it. For example, it returns /assets/7cf54cf2/img/logo.pnginsteadhttp://www.example.com/assets/7cf54cf2/img/logo.png
How can I use AssetManager or customize my code to get the full url? I cannot find the answer in the documentation, the only solution that I have come up with so far is to add it in front of me before returning.
I ran into this problem when trying to use this feature when creating HTML for email. Of course, the URLs in the email should contain the outline in front of it.
, ? !