framework/helpers/BaseHtml.php
public static function img($src, $options = [])
    {
        $options['src'] = Url::to($src);

        if (isset($options['srcset']) && is_array($options['srcset'])) {
            $srcset = [];
            foreach ($options['srcset'] as $descriptor => $url) {
                $srcset[] = Url::to($url) . ' ' . $descriptor;
            }
            $options['srcset'] = implode(',', $srcset);
        }

        if (!isset($options['alt'])) {
            $options['alt'] = '';
        }

        return static::tag('img', '', $options);
    }
public static function img($src, $options = [])
    {
        $options['src'] = Url::to($src);

        if (isset($options['srcset']) && is_array($options['srcset'])) {
            $srcset = [];
            foreach ($options['srcset'] as $descriptor => $url) {
                $srcset[] = Url::to($url) . ' ' . $descriptor;
            }
            $options['srcset'] = implode(',', $srcset);
        }

        if (!isset($options['alt'])) {
            $options['alt'] = '';
        }

        return static::tag('img', '', $options);
    }
public static function img ( $ src , $ options = [ ] ) { $ options [ 'src' ] = Url :: to ( $ src ) ; if ( isset ( $ options [ 'srcset' ] ) && is_array ( $ options [ 'srcset' ] ) ) { $ srcset = [ ] ; foreach ( $ options [ 'srcset' ] as $ descriptor => $ url ) { $ srcset [ ] = Url :: to ( $ url ) . ' ' . $ descriptor ; } $ options [ 'srcset' ] = implode ( ',' , $ srcset ) ; } if ( ! isset ( $ options [ 'alt' ] ) ) { $ options [ 'alt' ] = '' ; } return static :: tag ( 'img' , '' , $ options ) ; }
Generates an image tag.
@param array|string $src the image URL. This parameter will be processed by [[Url::to()]].
@param array $options the tag options in terms of name-value pairs. These will be rendered as
the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
If a value is null, the corresponding attribute will not be rendered.
See [[renderTagAttributes()]] for details on how attributes are being rendered.

Since version 2.0.12 It is possible to pass the `srcset` option as an array which keys are
descriptors and values are URLs. All URLs will be processed by [[Url::to()]].
@return string the generated image tag.
Generates an image tag . @param array|string $src the image URL . This parameter will be processed by [[ Url :: to () ]] . @param array $options the tag options in terms of name - value pairs . These will be rendered as the attributes of the resulting tag . The values will be HTML - encoded using [[ encode () ]] . If a value is null the corresponding attribute will not be rendered . See [[ renderTagAttributes () ]] for details on how attributes are being rendered .