Welcome Guest, Not a member yet? Register   Sign In
Add alt and title without array!
#1

[eluser]Jumps Like A Black Guy[/eluser]
I've looked everywhere and cant figure out how I can add a title and alt text to the image below. I keep getting errors with everything I try.

Code:
<td class="dt2">
     &lt;?php if(is_object($country)) echo $country->country_name ." ". img('path/to/country/images/' . $country->country_symbol . ".png"); ?&gt;
</td>

I've been pulling my hair out trying to solve this, but cant. I cant find a straight answer. I know this is possible without using an array.

Any help is a plus...

Thanks
#2

[eluser]mi6crazyheart[/eluser]
Here is an example how u can use CI's anchor() to show image with "alt" & "title". You just modify it as u'r need...

Code:
$image_properties = array(
    'src' => 'imageName.png',
    'alt' => 'place your alt value',
   'title' => 'place your titile',
    );                            

echo anchor('', img($image_properties ));
#3

[eluser]Jumps Like A Black Guy[/eluser]
I just want to add an alt and title to the code I have above... I dont want to use any image array... I want to know if this is possible.
#4

[eluser]John_Betong[/eluser]
I don't use the img(...) function and decided to check it out.

http://ellislab.com/codeigniter/user-gui...elper.html

Basically the function accepts either an image path or an array with all the image attributes.

To get round your problem try this:
Code:
echo ''
  . $country->country_name
  . " "
  . "<img >country_symbol .".png' "
  .   "alt='alt text goes here' "
  .   "title='title text goes here' "
  . "/>";
&nbsp;
In future I will try to utilise the img() function, it looks as though it will make my scripts more readable and also a lot more flexible to use the image attribute parameter.
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB