brand image in navbar

In bootstrap its easy to see how to set the brand image in the logo - but can anyone explain the steps for Yii2?

Do they go in /assets ?

Do you add ‘brandOptions’ into the NavBar::begin ? What is the syntax to link the /asset image ?

thx

An example :




//views/layouts/main.php

...

NavBar::begin([

  'brandLabel' => Html::img('@web/images/logo.jpg', ['alt'=>Yii::$app->name]),

  'brandOptions' => ['class' => 'myclass'],//options of the brand

  'options' => ['class' => 'navbar-inverse navbar-static-top']//options of the navbar

  ...

]);



You can save all your application images in the repository ‘/web/images’

@web’ is the alias of the web repository

Another example :




<img src="<?= yii\helpers\Url::to('@web/images/test.jpg') ?>" />



1 Like