CSS Background image path giving different result with replace-text-with-dimensions($img, $x, $y)

160 views
Skip to first unread message

Jitendra Vyas

unread,
Jun 11, 2012, 5:46:55 AM6/11/12
to compas...@googlegroups.com
I'm using a variable for images paths in a website $assetPath : "../images/"; and it's working fine as i want.

background:url(#{$assetPath}in-focus-tag2.png) no-repeat; to output background: url(../images/in-focus-tag2.png) no-repeat;

but when i use this 

@include replace-text-with-dimensions("#{$assetPath}in-focus-tag2.png")

it gives this background-image: url('/images/../images/in-focus-tag2.png?1334725966');

How to solve these problem?

1) I want to remove extra "/images/" while I'm using @include replace-text-with-dimensions
2)Want to remove ?1334725966 after img location

Chris Eppstein

unread,
Jun 11, 2012, 11:34:55 AM6/11/12
to compas...@googlegroups.com
Compass wants you to configure your asset locations in the config file and to use relative references in all cases within your stylesheets. You're just re-inventing a 1st class feature of compass by adding this config variable.

Chris

--
You received this message because you are subscribed to the Google Groups "Compass" group.
To view this discussion on the web visit https://groups.google.com/d/msg/compass-users/-/cJRZ9YDDMYsJ.
To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compass-users?hl=en.

Jitendra Vyas

unread,
Jun 11, 2012, 2:24:09 PM6/11/12
to compas...@googlegroups.com
I made separate variable for img path because i have images in 2 different directories. and now i also want to use  replace-text-with-dimensions
Chris

To unsubscribe from this group, send email to compass-users+unsubscribe@googlegroups.com.

Alan Hogan

unread,
Jun 11, 2012, 3:03:51 PM6/11/12
to compas...@googlegroups.com

On Jun 11, 2012, at 11:24 AM, Jitendra Vyas wrote:

> I made separate variable for img path because i have images in 2 different directories.

Why?

Jitendra Vyas

unread,
Jun 11, 2012, 3:08:52 PM6/11/12
to compas...@googlegroups.com
Because I'm using some images from existing site and some are new images which are in new project folder.

Roy Tomeij

unread,
Jun 11, 2012, 3:46:00 PM6/11/12
to compas...@googlegroups.com
Use two directories for them inside the images-folder.

Op maandag 11 juni 2012 21:08:52 UTC+2 schreef Jitendra Vyas het volgende:

Jitendra Vyas

unread,
Jun 11, 2012, 3:47:46 PM6/11/12
to compas...@googlegroups.com
How? Could you give some more details on it?


Thank you

Jitendra Vyas



--
You received this message because you are subscribed to the Google Groups "Compass" group.
To view this discussion on the web visit https://groups.google.com/d/msg/compass-users/-/lJnItEnlVrIJ.

To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-user...@googlegroups.com.

Roy Tomeij

unread,
Jun 11, 2012, 3:55:02 PM6/11/12
to compas...@googlegroups.com
I assume you now have something like /assets/image-dir-1 and /assets/image-dir-2. Make that /assets/images/dir-1 and /assets/images/dir-2 and you can just use the default Compass config, which uses the images directory. In your stylesheets you can then use the "dir-1/foo.jpg" path, which will look for the directory and file inside "/images".

Op maandag 11 juni 2012 21:47:46 UTC+2 schreef Jitendra Vyas het volgende:
How? Could you give some more details on it?


Thank you

Jitendra Vyas



On Tue, Jun 12, 2012 at 1:16 AM, Roy Tomeij <r...@tomeij.net> wrote:
Use two directories for them inside the images-folder.

Op maandag 11 juni 2012 21:08:52 UTC+2 schreef Jitendra Vyas het volgende:
Because I'm using some images from existing site and some are new images which are in new project folder.

On Tuesday, June 12, 2012 12:33:51 AM UTC+5:30, b01dface wrote:

On Jun 11, 2012, at 11:24 AM, Jitendra Vyas wrote:

> I made separate variable for img path because i have images in 2 different directories.

Why?

--
You received this message because you are subscribed to the Google Groups "Compass" group.
To view this discussion on the web visit https://groups.google.com/d/msg/compass-users/-/lJnItEnlVrIJ.

To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-users+unsubscribe@googlegroups.com.

Alan Hogan

unread,
Jun 11, 2012, 4:21:37 PM6/11/12
to compas...@googlegroups.com

On Jun 11, 2012, at 12:55 PM, Roy Tomeij wrote:

> I assume you now have something like /assets/image-dir-1 and /assets/image-dir-2. Make that /assets/images/dir-1 and /assets/images/dir-2 and you can just use the default Compass config, which uses the images directory. In your stylesheets you can then use the "dir-1/foo.jpg" path, which will look for the directory and file inside "/images".
>
Yes, do this.

You could even go crazy and define Sass functions to prefix your directories, so image-url(old-image("foo.jpg")) is the same as image-url("dir-1/foo.jgp"). Sass Script and functions are slightly advanced features of course, and unnecessary in this case.
Reply all
Reply to author
Forward
0 new messages