Skip to content

Instantly share code, notes, and snippets.

@djforth
Created September 13, 2013 12:38
Show Gist options
  • Save djforth/6550129 to your computer and use it in GitHub Desktop.
Save djforth/6550129 to your computer and use it in GitHub Desktop.
def nice_asset(a,thumb=nil)
if a and a.attachment and a.attachment.url
if a.is_image?
if thumb
image = image_tag a.attachment.images.send(thumb).url, :alt=>a.title
else
image = image_tag a.attachment.url, :alt=>a.title
end
if a.linkable && a.linkable.url
link_to image, a.linkable.url
else
image
end
else
a.attachment.url.split('/').last
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment