Home > OS >  add alt tag to yii2 php
add alt tag to yii2 php

Time:11-20

I am trying to add alt="app logo" to logo to my website with the help of Html::img tag but I keep getting errors on the website. This is my code:

                <?= Html::a(
                    Html::img(Configuration::get(Configuration::APP_LOGO_PATH)),
                    '/'.Yii::$app->language
                , ['class' => 'img-responsive']); ?>

CodePudding user response:

You can add alt in options

 <?= Html::a(
    Html::img(
       Configuration::get(Configuration::APP_LOGO_PATH)).'/'.Yii::$app->language,
      ['class' => 'img-responsive', 'alt' => 'app logo']
    );
 ?>

CodePudding user response:

From the documentation: "The tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag.":

Html::img(Configuration::get(Configuration::APP_LOGO_PATH), ['alt' => 'app logo'])
  • Related