sub views and rendering an HTML::img()

Hi all,

I have a layout in which i call


<?= $this->render('/common/main-sidebar'); ?>

in this main-sidebar.php i have somewhere in the space:


Html::img('@web/images/logo-panel/logo.png', [

                    'alt' => '',

                    'class' => 'img-responsive',

                    'data-src' => '@web/images/logo-panel/logo.png',

                    'width' => '58',

                    'height' => '40'

                ])

then Yii generates


<img class="img-responsive" src="@web/images/logo-panel/logo.png" width="58" height="40" alt="" data-src="@web/images/logo-panel/logo.png">

In fact Yii in his great generosity doesn’t interpret the @.

Do you know how bypassing this issue ?

Thx

have you tried




Html::img('/images/logo-panel/logo.png', [

                    'alt' => '',

                    'class' => 'img-responsive',

                    'data-src' => '/images/logo-panel/logo.png',

                    'width' => '58',

                    'height' => '40'

                ])




Strange. Seems the alias "@web" is not setted.

Try




Yii::setAlias('@web', Yii::$app->request->baseUrl);



Are you on basic or advanced application ?

Thx I’m on basic app

data-src will not work. Do like this :




'data-src' => Url::to('@web/images/logo-panel/logo.png')



If ‘@web’ is still not working, try :




Html::img(Yii::$app->baseUrl.'/images/logo-panel/logo.png', ...);



Thx it works great