• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attaching images to my web-page

#1
[eluser]2mato[/eluser]
Hello there I am trying to attaching images to my first CodeIgniter web-page :-), I am using this :

1- In config.php I configer the base url as shown ===>
$config['base_url'] = "http://localhost/ci/";

2- when adding an image to a view file i do like this ===>
<img src='&lt;?php echo base_url(); ?&gt;images/login_icon.gif'/>

What I am asking do i have to echo the base_url every time i want to add image or is there a better way to do that, Thanks.

#2
[eluser]mdvaldosta[/eluser]
You don't have to use the base url, omitting it will just show the images from a relative path (which I prefer to do anyways).

#3
[eluser]2mato[/eluser]
[quote author="mdvaldosta" date="1300738597"]You don't have to use the base url, omitting it will just show the images from a relative path (which I prefer to do anyways).[/quote]

sorry but i did not understand how i can do that?
My images are in a folder called images and on the same level is the application folder for CodeIgniter.

#4
[eluser]Atharva[/eluser]
You can use img function in html helper
Code:
$this->load->helper('html');
echo img('images/picture.jpg');

So you don't have to use base_url() each time. More info here

#5
[eluser]2mato[/eluser]
[quote author="Atharva" date="1300802653"]You can use img function in html helper
Code:
$this->load->helper('html');
echo img('images/picture.jpg');

So you don't have to use base_url() each time. More info here[/quote]

Thanks that work very good .... :-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.