Here is a working dev version of the sprite module. There are currently four ways to use it on your site...
- theme("sprite", $filepath, $alt = "", $title = NULL, $attributes = array(), $context = "general", $override_width = NULL, $override_height = NULL, $offset_width = NULL, $offset_height = NULL)
- "Sprite HTML" image formatting option in views and in the content type display fields config page
- "<imagecache_preset> sprite" image formatting option in views and in the content type display fields config page
- sprite_register($filepath = NULL, $context = "general", $override_width = NULL, $override_height = NULL, $offset_width = NULL, $offset_height = NULL)
Here are the known issues / things I'm still working on...
- Currently it only works with jpg and gif output types... pngs are still buggy
- Currently it doesn't use ImageAPI, so it requires GD
- Parsing the CSS for background images and adding them to a sprite
- Optimizing the code to run quicker
- Trying to find a way to apply the imagecache preset without reading the imagecache file from disk to avoid image degradation due to multiple lossy compressions
- Cleaning up the code and documenting it
Here are some notes...
- If you call theme() or sprite_register() with a path to an imagecache file and it doesn't exist yet, the sprite module will try to determine the preset and will generate the imagecache file automatically
- While the module improves frontend performance in most cases, I have experienced a performance hit when implementing the sprites for multiple larger images... so don't use it blindly sometimes you might be better off without it
- I alluded to it in the known issues list, but you will see some image quality degradation since you are using jpegs as your source material (and in the case of an imagecache image, a jpeg of a jpeg). If you notice an image quality drop you can bump up the Image Toolkit quality setting
- There are some configuration settings and the ability to flush generated sprites via Site Configuration > Sprite
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | sprite.tar_.gz | 12.67 KB | d.clarke |
| #1 | sprite.tar_.gz | 12.52 KB | d.clarke |
Comments
Comment #1
d.clarke commentedUpdate to replace the term 'context' in the sprite module to 'registry' to eliminate any potential confusion with contexts in ctools and core in Drupal 7. I also think it is the term that Aaron originally intended to use for that feature.
Comment #2
gagarine commentedIts committed?
Comment #3
d.clarke commentedI'm still working on getting commit access, but in the meantime here is a cleaned up version of the code.
Comment #4
aaron commentedthis looks really good! thanks for the hard work, dale!
Comment #5
d.clarke commentedThis has been committed and a dev version has been published. Please use that version moving forward.
Thanks,
Dale
Comment #6
gagarine commentedNice!!