Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Commit

Permalink
Added support for :title
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Blackstone committed Jan 26, 2010
1 parent 3524df7 commit eeb319c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions README.rdoc
@@ -1,5 +1,5 @@

=AutoSprite
=AutoSprite 1.0.4


An easy, automated CSS image sprite creator.
Expand Down Expand Up @@ -32,6 +32,11 @@ Suppose you have 10 images on your homepage. Rather than downloading 10 seperat
<%= image_tag 'sprites/logo.png' %>
<%= image_tag 'sprites/icon1.jpg' %>

As of Auto Sprite 1.0.4 image_tag can be passed a :title giving icons a hover text..

<%= image_tag "sprites/stuff.png", :title => "I like Ice Cream" %>


5. Reload after adding any new images to sprites/ and enjoy your now faster rendering website.


Expand All @@ -43,6 +48,7 @@ You'll notice that should auto_sprite be removed, your application will still wo
- Any image format supported by RMagick should work.
- Images of mixed sizes are not a problem.


=Details

Whenever rails reloads, it will automatically generate two files:
Expand All @@ -51,11 +57,9 @@ Whenever rails reloads, it will automatically generate two files:
RAILS_ROOT/public/images/auto_sprite.png


The image tag will automatically generate a SPAN tag for any images located in the sprite directory.

<span class="_as_logo_png"></span> instead of <img src="/images/sprites/logo.png" />
The image tag will automatically generate a div tag for any images located in the sprite directory.

Note: before 1.0.3, div tags were generated but this sometimes generated invalid HTML.
<div class="_as_logo_png"></div> instead of <img src="/images/sprites/logo.png" />


Here is an exmplmple of the stylehseet that would be generated if you had two files face3.png and face4.png
Expand Down
3 changes: 1 addition & 2 deletions auto_sprite.gemspec
Expand Up @@ -2,10 +2,9 @@ spec = Gem::Specification.new do |s|

require 'fileutils'
s.name = "auto_sprite"
s.version = "1.0.3"
s.version = "1.0.4"
s.author = "Stephen Blackstone"
s.email = "sblackstone@gmail.com"
s.rubyforge_project = "autosprite"
s.homepage = "http://fargle.org/auto_sprite"
s.platform = Gem::Platform::RUBY
s.summary = "A fully-Automagic Sprite Builder"
Expand Down
3 changes: 2 additions & 1 deletion lib/auto_sprite.rb
Expand Up @@ -57,8 +57,9 @@ def self.included(base)
base.class_eval do
def image_tag(source, options = {})
src = path_to_image(source)
title = (options[:title].nil? or options[:title].empty?) ? "" : "title='#{options[:title]}'"
if src =~ /\/images\/sprites/
"<span class='#{AutoSprite.generate_css_name(src)}'></span>"
"<span #{title} class='#{AutoSprite.generate_css_name(src)}'></span>"
else
super(source,options)
end
Expand Down

0 comments on commit eeb319c

Please sign in to comment.