views:

246

answers:

3

I have some css files that are deployed in a feature scoped to "site"

They contains some calls to images (also deployed by the solution) and so the paths are things like

background: #ffcc00 url(  '/sites/portal/Style Library/CSS/PersonalCenter.gif' ) repeat-x;

However I would quite like to be able to deploy to other "sites/XXXX" without having to change the url in all the css files!

I cannot just place them in the top level URL as it has its own styles etc and it would be confusing to mash styles from subs-sites into it.

Is there somewhere else I should be storing things like this?

Thanks!

+1  A: 

How about placing them (the images) in _layouts, then you could use

url(  '/_layouts/images/PersonalCenter.gif' )
Johan Leino
+1  A: 

There are two major options for this:

1. Store your images in the Style Library.

Browse to /sites/portal/Style Library/Images and create a folder there to store your images. This appears to be similar to what is already being done in the CSS file. Use a relative path in the CSS file to avoid the /sites/portal part of the URL.

Advantages: Version control, no need to worry about deployment across multiple servers.

2. Store your images on the file system.

Create a folder for the images specific to your solution, e.g. at

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES\siteXXX

This maps to the folder that Johan mentions where you would use

/_layouts/images/siteXXX/image.gif

to reference your images.

Advantages: Performance (maybe) depending on how the server is configured.

Recommendation: Use the Style Library if possible. Version control alone is a huge benefit.

Alex Angas
+1  A: 

Thanks for your answers... In the end I have remembered about relative paths and

background: #ffcc00 url(  '../CSS/PersonalCenter.gif' ) repeat-x;

works just fine.

The images/css files remain in the Style Library which has been useful to check CSS changes before committing them to the main feature and doing a 'proper' release of the solution

Now why did I not just do that from the start !?

Aidan