Welcome Guest, Not a member yet? Register   Sign In
Image Path and Links in View-Files
#1

[eluser]noro[/eluser]
Hiho,

I have an noob question. If i declare an Image File i have to write for example:

<img src="&lt;?=base_url();?&gt;image/btn_left.gif" />

My designer starts to hate me Wink

The Image Folder is in the root of CI. Can I write it more easy?
#2

[eluser]xzela[/eluser]
Check out the Snappy_Source helper:

http://codeigniter.com/wiki/Snappy_Source/

It's a pretty good helper for loading images and scripts.
#3

[eluser]ChangedNames[/eluser]
Something I tend to do is use absolute paths to the root of the website and if the images folder doesn't actually reside there re-route with .httpd or .htaccess. This is an apache approach but it would be something like this:

Code:
<img src="/images/foo.jpg"/>

foo.jpg actually resides in /system/application/views/images/foo.jpg so I send it that way with .htaccess like this:

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images/(.*) /system/application/views/images/$1
#4

[eluser]noro[/eluser]
Ok, I will try the Mod_rewrite version. Snappy seems to be a goog helper if you use not so much pictures.

Maybe I move my Homepage pictures into the view Folder, that would make it much easier.
#5

[eluser]noro[/eluser]
Ok, now I am very confused. My Pictures are in the Root Folder, I changed nothing (nothing I noticed) and now I can write src="image/Picture.jpg" and get the picture.. intresting and perfect ^^




Theme © iAndrew 2016 - Forum software by © MyBB