Answer the question
In order to leave comments, you need to log in
How to include an image in a widget in Yii2?
Hello! I am writing a widget for yii2 and I want to localize the image in the widget folder and not in the images folder of the site. If Widget widget folder is located in frontend/components/widgets and contains Widget.php, WidgetAssets.php files and assets c js and css folder included in WidgetAssets, how do I attach related images to the widget so that they go with the widget, like access these images?
Answer the question
In order to leave comments, you need to log in
Thanks ValentineK for pushing me in the right direction. Found the answer here
Create your own AssetBundle class, register it when calling your widget (possible in the init() method) and use Yii::$app->assetManager->getAssetUrl() to access images.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question