Setting attributes on an img tag for new image_slider template

Permalink
I am creating a new template for the image_slider. I need to add attributes and values to the html img tag. This is what the img tag looks like from the theme I am using:

<img src="assets/img/sliders/4.jpg"  alt="darkblurbg"  data-bgfit="cover" data-bgposition="left top" data-bgrepeat="no-repeat">


In the default view.php file there is this:

$tag = Core::make('html/image', array($f, false))->getTag();


And to set the alt attribute there is this:

$tag->alt("slide");


Are there equivalent functions for the other attributes that I need to set ?

$tag->data-bgfit("cover");


Or do I need to create these attributes first and then set them ? Is there a createAttribute function ?

Also, is there some way to inspect the $tag object for it's functions ? Bear with me if this is a simple question, I am new to PHP.

Thanks,

Warren Bell

warish
 
hutman replied on at Permalink Best Answer Reply
hutman
Unfortunately this doesn't seem to be documented anywhere (nor can I find where it happens in the code) but you can do

$tag->dataBgfit("cover");


And it will put your data-bgfit="cover" attribute on the element.