diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3be9aa3..f7b99b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,10 +4,12 @@ Yii Framework 2 bootstrap5 extension Change Log
2.0.5 under development
-----------------------
+- Enh #78: Navbar has new attribute `brandImageOptions` (EvilKarter)
- Bug #74: Bootstrap5 Button is not registering clientEvents (simialbi)
- Bug #72: Nav::isItemActive(): Return value must be of type bool, int returned (hirenbhut93)
- Bug #62: Navbar can now accept `collapseOptions` to be `false` (theblindfrog)
+
2.0.4 November 30, 2022
-----------------------
diff --git a/src/NavBar.php b/src/NavBar.php
index 45e2555..4dc4289 100644
--- a/src/NavBar.php
+++ b/src/NavBar.php
@@ -75,6 +75,12 @@ class NavBar extends Widget
* @since 2.0.8
*/
public $brandImage = false;
+
+ /**
+ * @var array the HTML attributes of the brand image.
+ * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
+ */
+ public $brandImageOptions = [];
/**
* @var array|string|bool $url the URL for the brand's hyperlink tag. This parameter will be processed by [[\yii\helpers\Url::to()]]
* and will be used for the "href" attribute of the brand link. Default value is false that means
@@ -144,7 +150,7 @@ class NavBar extends Widget
$this->offcanvasOptions['id'] = "{$this->options['id']}-offcanvas";
}
if ($this->brandImage !== false) {
- $this->brandLabel = Html::img($this->brandImage);
+ $this->brandLabel = Html::img($this->brandImage, $this->brandImageOptions);
}
if ($this->brandLabel !== false) {
Html::addCssClass($this->brandOptions, ['widget' => 'navbar-brand']);
diff --git a/tests/NavBarTest.php b/tests/NavBarTest.php
index e9caaf9..85f042a 100644
--- a/tests/NavBarTest.php
+++ b/tests/NavBarTest.php
@@ -48,6 +48,17 @@ EXPECTED;
$this->assertContains('', $out);
}
+
+ public function testBrandImageOptions()
+ {
+ $out = NavBar::widget([
+ 'brandImage' => '/images/test.jpg',
+ 'brandImageOptions' => ['alt' => 'test image'],
+ 'brandUrl' => '/',
+ ]);
+
+ $this->assertContains('', $out);
+ }
public function testBrandLink()
{