简体   繁体   中英

add alt tag to yii2 php

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']); ?>

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']
    );
 ?>

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'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM