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)
    image = image_tag(asset.attachment.url(:thumbnail))
  else
    image = image_tag(default_asset_thumbnail(asset))
  end
  asset_icon_link(asset, image)
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

#asset_tile(asset) ⇒ Object



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

def asset_tile(asset)
  if asset.attachment.exists?(:tile)
    image = image_tag(asset.attachment.url(:tile))
  else
    image = image_tag(default_asset_thumbnail(asset))
  end
  asset_tile_link(asset, image)
end


29
30
31
32
33
34
35
# File 'app/helpers/tenon/asset_helper.rb', line 29

def asset_tile_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



37
38
39
40
41
42
43
# File 'app/helpers/tenon/asset_helper.rb', line 37

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