Cannot get image_url() working

223 views
Skip to first unread message

Charles Roper

unread,
Nov 1, 2009, 10:33:24 AM11/1/09
to compas...@googlegroups.com
Probably doing something really dumb here, but I cannot get image_url()
to work.

This is my config (it's a Staticmatic site):

require 'susy'

ROOT = File.join(File.dirname(__FILE__), '..')
puts "Site root is: " + File.expand_path(ROOT)

output_style = :nested
project_path = ROOT # must be set for Compass to work
sass_dir = "src/stylesheets" # dir containing Sass / Compass
source files
css_dir = "site/stylesheets"
images_dir = "site/images"

# Enable relative paths to assets via compass helper functions.
relative_assets = true

Here's a bit of relevant Sass:

body
background= image_url("Dob-002-bw.jpg")

And this is the CSS that gets emitted:

body {
background: url('Dob-002-bw.jpg?'); }

The URL is not referring to the images directory as it should be.

Any ideas as to what's going on here?

Cheers,
Charles

Charles Roper

unread,
Nov 1, 2009, 12:50:31 PM11/1/09
to compas...@googlegroups.com
I've done a bit of poking around and it looks like the
compute_relative_path method is returning nil, possibly because the
options[:css_filename] isn't populated.

Here's a quick output of the options hash I gathered by putting the
following in urls.rb

options.each do |k,v|
puts "#{k}: #{v}"
end

cache: true
load_paths:
config/../src/stylesheetsC:/ruby/lib/ruby/gems/1.8/gems/compass-0.8.17/frameworks/blueprint/stylesheetsC:/ruby/lib/ruby/gems/1.8/gems/compass-0.8.17/frameworks/compass/stylesheetsC:/ruby/lib/ruby/gems/1.8/gems/compass-0.8.17/frameworks/yui/stylesheetsC:/ruby/lib/ruby/gems/1.8/gems/compass-susy-plugin-0.6.3/sass
line_comments: true
style: nested
cache_location: ./.sass-cache
property_syntax:

Could this be a Staticmatic problem?

Charles

Chris Eppstein

unread,
Nov 1, 2009, 12:55:07 PM11/1/09
to compas...@googlegroups.com
This config expects you to have the following layout:

ROOT
| - config
|   | - compass.config
|
| - src
|   | - stylesheets
|
| - site
|   | - stylesheets
|   | - images

If that's right then you should expect to see an error message like so:

WARNING: 'Dob-002-bw.jpg' was not found (or cannot be read) in /Users/chris/foo/config/../site/images

That should tell you where it was looking for an image if it can't find it.

If staticmatic is not setting :css_filename when it creates a new Sass::Engine to process that sass file, then that would effectively disable the feature....

chris

Charles Roper

unread,
Nov 1, 2009, 4:26:31 PM11/1/09
to compas...@googlegroups.com
2009/11/1 Chris Eppstein <ch...@eppsteins.net>:

> This config expects you to have the following layout:
> ROOT
> | - config
> |   | - compass.config
> |
> | - src
> |   | - stylesheets
> |
> | - site
> |   | - stylesheets
> |   | - images
> If that's right then you should expect to see an error message like so:
> WARNING: 'Dob-002-bw.jpg' was not found (or cannot be read) in
> /Users/chris/foo/config/../site/images

Chris, that's precisely as the layout is, but I don't get that error
message. If I intentionally give a nonexistant path to the image in my
sass, then I get the message:

body
background= image_url("foo/Dob-002-bw.jpg")

...

WARNING: 'Dob-002-bw.jpg' was not found (or cannot be read) in

config/../site/images/foo

> That should tell you where it was looking for an image if it can't find it.
> If staticmatic is not setting :css_filename when it creates a new
> Sass::Engine to process that sass file, then that would effectively disable
> the feature....

I guess that must be it then.

Cheers,
Charles

Reply all
Reply to author
Forward
0 new messages