Welcome Guest, Not a member yet? Register   Sign In
HELP: subdomain how would i access my images?
#1

[eluser]dippy[/eluser]
Hello. I need some help/advice here with showing an image.

I have a subdomain which looks like this: http://subdomain.domain.com

Now i have my base_url() is set like this:
Code:
$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '')
                      .'://'.$_SERVER['HTTP_HOST'].str_replace('//','/',dirname($_SERVER['SCRIPT_NAME']).'/');

Now, in my CSS file that is in "assets/css" the css should be the following:
Code:
#header_image {
    position:relative;
    background:url('../images/hometop.jpg') no-repeat;
    height:134px;
}
where my images are in "assets/images"
CORRECT?


Now, I am testing some css that uses an image and I am using a css/style sheet inside my view file. How would I show an image then?

Here is my file structure:
-root
-application
-codeigniter folders
-assets
-images
-css
-images
-system
-.htaccess
-index.php
-robots.txt

Should it be the following:
Code:
#header_image {
    position:relative;
    background:url('../../assets/images/hometop.jpg') no-repeat;
    height:134px;
}

Please help me and let me know if i am correct at all here?? If i am not please let me know where I went wrong because my image is not showing up.

Any help would be great!!

Thank you in advance!
#2

[eluser]Aken[/eluser]
Just use an absolute path.

Code:
background: url('/assets/images/hometop.jpg') no-repeat;

I should say, though, that your CSS should be consolidated into a single CSS file, and not generated in individual pages.
#3

[eluser]dippy[/eluser]
[quote author="Aken" date="1347345543"]Just use an absolute path.

Code:
background: url('/assets/images/hometop.jpg') no-repeat;

I should say, though, that your CSS should be consolidated into a single CSS file, and not generated in individual pages.[/quote]

I totally agree. I will not use the style in the view page anymore. I was just testing something and I admit I was being lazy and put it in the view file.

Now, in my CSS file that is in “assets/css” the following css should work fine and the image will show?

Code:
#header_image {
    position:absolute;
    background:url('../images/hometop.jpg') no-repeat;
    height:134px;
}

Where my images are in “assets/images” correct?

Thanks again for your help and reply!




Theme © iAndrew 2016 - Forum software by © MyBB