简体   繁体   中英

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.

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... ['}

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