Page 1 of 1
Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 11:45 am
by thomahawk
Dear forum members
I just installed a fresh CMSMS and have a strange problem creating the general template: The images used in stylesheet (mostly div background images) do not work.
I checked the links, for example "images/button.png", they do work when I call them directly as an URL path, or when I put the same CSS directly into the template page (using the {literal} tag). The stylesheets as such do also work (fonts and colors etc. are displayed correctly). Only the images do not appear.
I used the latest stable release, 1.9.4.1 "Faanui"
It seems as if the stylesheet uses an other path to the directory, but I have done several CMSMS sites and never got this problem... I have no clue what else to do, any suggestions?
Thanks,
Thom
Re: Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 11:50 am
by thomahawk
By the way, also using the complete url to the image in the stylesheet does work, f.e.
http://www.homepage.com/images/button.png, but images/button.png does not.
Re: Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 1:05 pm
by M@rtijn
You kind of already answered yourself
When using 'images/button.png' the server doesn't know to what path that relates. Using a full url, solves it.
Another way, the proper CMSMS way, to solve it:
Use {cms_stylesheet} in your page template & add [[root_url]] before your links in the css files.
Like this:
Code: Select all
background: url([[root_url]]/uploads/images/something.jpg);
Re: Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 1:15 pm
by thomahawk
Thanks for your message, Martijn
I will try your solution.
However, why is this necessary now? I have done so many CMSMS sites before, and it always worked by just placing the usual internal link into the stylesheet. I just checked again and it is true, I used for example
body {
background-color: #252525;
background-image:url(images/background.jpg);
No alteration was necessary in CMS Made Simple 1.6.7 "Teremba Bay".
Thomas
Re: Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 1:21 pm
by uniqu3
Stylesheets are bein cached in /tmp/cache folder meaning you would need to use ../../images/ or /images in case you don't like full url that is created with [[root_url]].
Before 1.8.xx stylesheets were not cached in a folder meaning path to stylesheet looked like being in root folder where path to images was correct.
Re: Image links not working in Stylesheet
Posted: Sat Mar 26, 2011 1:27 pm
by thomahawk
Thanks unique3, that explains everything. I suppose this should be mentioned in
http://wiki.cmsmadesimple.org/index.php ... tylesheets
Re: Image links not working in Stylesheet
Posted: Sun Mar 27, 2011 3:03 am
by Wishbone
It is in the help in the backend.. Extensions -> Tags -> cms_stylesheet
Your old install was using {stylesheet}, which is relative to the root directory. The cms_stylesheets are served up from somewhere in /tmp. If you go back to {stylesheet} your old stylesheets will work.
Re: Image links not working in Stylesheet
Posted: Sun Mar 27, 2011 9:18 am
by RonnyK
Correct,
there are 2 methods of calling stylesheets {stylesheet} which does all relative by default, or the newer {cms_stylesheet} which works cache-based, and thus needs the full path. As the stylesheet is cached in another folder. To make the full path appear, use the [[root_url]]/ in front of the relative images and they will appear.
Ronny
Re: Image links not working in Stylesheet
Posted: Sun Mar 27, 2011 7:26 pm
by Dr.CSS
@thomahawk
I would also suggest you move your them images into a sub-directory in uploads/ I would never put anything in root/images, as it is only supposed to be used for cmsms itself...