Q
Q
qorp2016-05-23 19:52:40
Yii
qorp, 2016-05-23 19:52:40

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

2 answer(s)
Q
qorp, 2016-05-24
@qorp

Thanks ValentineK for pushing me in the right direction. Found the answer here

V
ValentineK, 2016-05-24
@ValentineK

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 question

Ask a Question

731 491 924 answers to any question