2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/has_assets/custom_redcloth_tags.rb', line 2
def after_transform(text)
text.gsub! /\[asset\(([^\)]+)\)\]/ do |s|
asset_id, size = $1.split('|')
asset = Asset.find_by_id(asset_id)
return if asset.nil?
html = "<a href=\"#{asset.public_filename}\" class=\"fancybox\" rel=\"group\">"
if asset.is_image?
html << "<img src=\"#{asset.public_filename(size)}\" alt=\"#{asset.description}\" />"
else
html << asset.description.titleize
end
html << '</a>'
end
text.chomp!
end
|