I am trying to add non HTML attribute in htmlOptions array of Yii's CHTML::image($url, $alt, $htmlOptions)
, but in rendered page these attributes does not get added.
Basically i want to use lazy loading of images which needs to store original image url in 'data-origional'
and a placeholder in SRC tag. attribute. For some reasons i can't use a direct HTML <img />
tag in my code.
Thanks for any suggestions guys.
This code works fine:
echo CHtml::image('http://google.com/images/srpr/logo3w.png', '', array(
'data-original' => 'original',
'another-attribute' => 'bla-bla-bla',
));
It returns:
<img
alt="" src="http://google.com/images/srpr/logo3w.png"
another-attribute="bla-bla-bla"
data-original="original"
>