Welcome Guest, Not a member yet? Register   Sign In
What is the full (or relative) path to an image of views/images?
#1

[eluser]LrDarko[/eluser]
This code is written on a view:

#crumbs li a {
background:url(images/crumbs.gif) no-repeat right center;
}

It doesn't show any image...
How is that possible?
#2

[eluser]danmontgomery[/eluser]
In a CSS file (.css), image paths are relative to the CSS file.

In anything rendered by CI, the file actually being displayed is index.php, so any paths are relative to that file.
#3

[eluser]LrDarko[/eluser]
The CSS code is not in a .css is written on a view because it just seems that CI on my macbook doesn't like it in a single .css file.

So if I have a folder in views called "images" and my image there... the relative path written on my first post was right, wasn't it?

So, why is not showing any images?
#4

[eluser]danmontgomery[/eluser]
[quote author="LrDarko" date="1271806313"]The CSS code is not in a .css is written on a view because it just seems that CI on my macbook doesn't like it in a single .css file.[/quote]

I'll leave this one alone...

[quote author="LrDarko" date="1271806313"]So if I have a folder in views called "images" and my image there... the relative path written on my first post was right, wasn't it?[/quote]

After some testing, it appears that if the CSS is in the view, the path is relative to the URL in the address bar of the browser, so:

Quote:http://www.mydomain.com/path/to/this/page

The browser would be looking for http://www.mydomain.com/path/to/this/pag...crumbs.gif

Also, in Firefox you can right-click on any element and select "View Background Image" which will show you the path it's using.
#5

[eluser]LrDarko[/eluser]
Sorry but my web is not uploaded to any hosting, is in localhost.

My url is the URL of my controller, do you say I have to move my image to the controller folder?

I am very confused... sorry mate.
#6

[eluser]danmontgomery[/eluser]
Whether or not you're working locally has nothing to do with whether or not css files are used...

I would never put images anywhere inside of the application directory, I always keep any assets outside of codeigniter in their own directory (usually named assets/) for ease of use and uniformity. You don't "have" to do anything. If you don't want to change your code, you'd want to create a path on your filesystem that matches the one the browser is currently looking for. If you don't want to move the CSS out of the view you probably want to use an absolute path and point to images somewhere outside of the application.




Theme © iAndrew 2016 - Forum software by © MyBB