Vishal Shetty
Vishal Shetty

Reputation: 1668

How to display image & it's attribute in Codeigniter

I have HTML code in my html file which is working

<img class="uk-text-center" 
   data-uk-scrollspy="{cls:'uk-animation-slide-left', delay:600}" 
   alt="download our app" 
   src="assets/images/app.jpg">

I am now using Codeigniter framework so the above line is not working in codeigniter code.

so write above line as

<?php 
    $img_prop=array('src'=>'assets/images/app.jpg',
                     'alt'=>'download our app',
                     'style'=>'display: block; margin-right: auto; margin-left: auto;');
    echo img($img_prop);
?>

The above line works well but there is one attribute missing in above code.

data-uk-scrollspy="{cls:'uk-animation-slide-left', delay:600}"

I am not able to add this attribute in above php code, please help me that how to add this attribute to above php code & make it work.

Upvotes: 0

Views: 179

Answers (1)

Nikhil.nj
Nikhil.nj

Reputation: 240

It's easy you can add it like as follow..

$img_prop=array('src'=>'assets/images/app.jpg',
                 'alt'=>'download our app',
                 'data-uk-scrollspy'=>"{cls:'uk-animation-slide-left', delay:600}",
                 'style'=>'display: block; margin-right: auto; margin-left: auto;');

print_r($img_prop);

Check it and let me know if you face any problem... ['}

Upvotes: 1

Related Questions