Module: Tenon::AssetHelper

Defined in:
app/helpers/tenon/asset_helper.rb

Instance Method Summary collapse

Instance Method Details

#asset_icon(asset) ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/helpers/tenon/asset_helper.rb', line 3

def asset_icon(asset)
  if asset.attachment.exists?(:thumbnail)
    i = image_tag(asset.attachment.url(:thumbnail))
  else
    i = image_tag(default_asset_thumbnail(asset))
  end
  asset_icon_link(asset, i)
end


12
13
14
15
16
17
18
# File 'app/helpers/tenon/asset_helper.rb', line 12

def asset_icon_link(asset, icon)
  if asset.is_image?
    link_to(icon, [:crop, asset], crop_options(asset))
  else
    link_to(icon, asset.attachment.url, target: '_')
  end
end

#default_asset_thumbnail(asset) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/tenon/asset_helper.rb', line 20

def default_asset_thumbnail(asset)
  if asset && asset.attachment_content_type.match('video')
    'tenon/thumb-video.png'
  else
    'tenon/thumb-doc.png'
  end
end