Re: [jQuery] Change all CSS background images url

2009-11-17 Thread Liam Byrne

Why are you using a root-relative URL ?

If the entire site is in a folder, and then you move everything into 
another folder, everything will stay relative.


Therefore, having the path as img (or whatever the relative path to 
that folder is) should work, no ?


Liam

nomen wrote:

Hi all:

I have a website. All my images are in /img directory.
Now, my client needs to put the site in a subdirectory, so, my
images are now in /subdir/img.
In the future, maybe we have to change the site to another
subdirectory.
I don´t want to change all my CSS anytime the client changes the
subdirectory.
So my question is:
Is there a simple way to change all CSS background-image
property with the next logic:

   Change all the existing CSS background-image
properties in this way:
   if the url starts with /img change to /subdir/
img else do nothing

   Thank you for your help in advance.
  




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.425 / Virus Database: 270.14.67/2506 - Release Date: 11/16/09 07:43:00


  




[jQuery] Change all CSS background images url

2009-11-16 Thread nomen
Hi all:

I have a website. All my images are in /img directory.
Now, my client needs to put the site in a subdirectory, so, my
images are now in /subdir/img.
In the future, maybe we have to change the site to another
subdirectory.
I don´t want to change all my CSS anytime the client changes the
subdirectory.
So my question is:
Is there a simple way to change all CSS background-image
property with the next logic:

   Change all the existing CSS background-image
properties in this way:
   if the url starts with /img change to /subdir/
img else do nothing

   Thank you for your help in advance.



Re: [jQuery] Change all CSS background images url

2009-11-16 Thread Liam Potter

it would be a bad idea to do this with javascript.
I'd recommend simply using find and replace all in your css.

find url(/img
replace url(/subdir/img

nomen wrote:

Hi all:

I have a website. All my images are in /img directory.
Now, my client needs to put the site in a subdirectory, so, my
images are now in /subdir/img.
In the future, maybe we have to change the site to another
subdirectory.
I don´t want to change all my CSS anytime the client changes the
subdirectory.
So my question is:
Is there a simple way to change all CSS background-image
property with the next logic:

   Change all the existing CSS background-image
properties in this way:
   if the url starts with /img change to /subdir/
img else do nothing

   Thank you for your help in advance.

  




Re: [jQuery] Change all CSS background images url

2009-11-16 Thread Michel Belleville
First idea that comes to mind is to let your client define another site
base, you then don't even have to change your css as the apparent site base
would be the client's sub-directory.
You do that using the base tag as shown here :
http://www.w3schools.com/TAGS/tag_base.asp

Hope it helps.

Michel Belleville


2009/11/16 nomen gaston...@gmail.com

 Hi all:

I have a website. All my images are in /img directory.
Now, my client needs to put the site in a subdirectory, so, my
 images are now in /subdir/img.
In the future, maybe we have to change the site to another
 subdirectory.
I don´t want to change all my CSS anytime the client changes the
 subdirectory.
So my question is:
Is there a simple way to change all CSS background-image
 property with the next logic:

   Change all the existing CSS background-image
 properties in this way:
   if the url starts with /img change to /subdir/
 img else do nothing

   Thank you for your help in advance.