Please note: this blog has been migrated to a new location at https://jakesgordon.com. All new writing will be published over there, existing content has been left here for reference, but will no longer be updated (as of Nov 2023)

Sprite Factory 1.5.2

Sun, Jan 13, 2013

I have released a minor update to the sprite-factory ruby gem. This version adds 3 small features:

Support for .ico files

If you are using RMagick as your image library you can now include .ico image files as input to the sprite factory.

(see issue #18)

Order pseudoclasses by importance

If you are generating CSS psuedoclasses (e.g. :hover, :active, :visited etc) then the generated CSS class definitions will now be sorted in order of importance:

img.icon         { ... }
img.icon:link    { ... }
img.icon:visited { ... }
img.icon:focus   { ... }
img.icon:hover   { ... }
img.icon:active  { ... }

(see issue #20)

Replaced :csspath with :cssurl

The :csspath option in earlier versions allowed you to customize the path generated within the css url() function but did not allow you to customize the url() function itself. With the new Rails asset pipeline, and in particular the sass-rails gem, it can be desirable to use the new Sass helper methods instead of the url() method itself. In particular using image-url() instead of url().

The new :cssurl option replaces the legacy :csspath but allows you to customize the entire value, including the outer url() as well as the inner path.

The simple case of a CDN prepend works the same way as before:

SpriteFactory.run!('icons', :cssurl => "http://s3.amazonaws.com/")

generates

background: url('http://s3.amazonaws.com/icons.png')

The more advanced cases ($IMAGE token replacement, or lambda functions) now expect the caller to take responsibility for including the appropriate outer url() or image-url() function call:

SpriteFactory.run!('images/icons', :cssurl => "image-url('$IMAGE')")

generates

background: image-url('icons.png')

The “Customizing the CSS Image Url” section in the README has more details.

IMPORTANT: If you previously used the $IMAGE or lambda versions of the :csspath option, you will need to modify your code to use the new :cssurl and ensure you wrap your values with an outer url(...)

(see issue #21)


Installation

As usual, installation is just a gem away:

$ gem install sprite-factory

And detailed instructions can be found in the README.

Let me know if you have any problems/feedback.

Enjoy!