Skip to content

Instantly share code, notes, and snippets.

@jcstringer
Created October 27, 2011 19:04
Show Gist options
  • Save jcstringer/1320503 to your computer and use it in GitHub Desktop.
Save jcstringer/1320503 to your computer and use it in GitHub Desktop.
def logo(options={})
options.reverse_merge!({:category => "logo", :id => "logo", :alt => @store.branded_name, :link_title => @store.branded_name})
return "" unless @store
logo_img = ""
if logo_asset = @store.attachments.find_by_category(options[:category])
logo_img += image_tag(logo_asset.url, {:id => options[:id], :alt => options[:alt]})
elsif @store.logo?
logo_img += image_tag(@store.logo.url, {:id => options[:id], :alt => options[:alt]})
end
controller.action_name.eql?('index') ? logo_img : link_to(logo_img, "/", :title => options[:link_title])
end
def header_img(category="header", id="header-img", alt=nil)
if @store && header = @store.attachments.find_by_category(category)
alt ||= header.alt_text
image_tag(header.url, {:id => "header-img", :alt => alt})
else
return ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment