Module: Smithy::AssetsHelper

Included in:
AssetsDatatable
Defined in:
app/helpers/smithy/assets_helper.rb

Instance Method Summary collapse

Instance Method Details

#asset_image_tag(asset_id) ⇒ Object



3
4
5
6
7
# File 'app/helpers/smithy/assets_helper.rb', line 3

def asset_image_tag(asset_id)
  asset = Smithy::Asset.find_by_id(asset_id)
  return unless asset
  image_tag(asset.url, :alt => asset.name)
end


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/smithy/assets_helper.rb', line 9

def asset_preview_link(asset_id)
  asset = Smithy::Asset.find_by_id(asset_id)
  return unless asset
  link_to attachment_url(asset, :file) do
    if asset.file_type == :image
      attachment_image_tag(asset, :file, :fit, 30, 30, alt: '')
    elsif asset.file_type == :direct_image
      attachment_image_tag(asset, :file, width: 30, alt: '')
    else
      image_tag file_type_icon(asset), alt: ''
    end
  end
end

#file_type_icon(asset) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/smithy/assets_helper.rb', line 23

def file_type_icon(asset)
  case asset.file_type
  when :image
    nil
  when :pdf
    'smithy/icons/pdf.png'
  when :word
    'smithy/icons/doc.png'
  when :excel
    'smithy/icons/xls.png'
  when :powerpoint
    'smithy/icons/ppt.png'
  when :text
    'smithy/icons/txt.png'
  when :document
    'smithy/icons/_page.png'
  when :default
    'smithy/icons/_blank.png'
  end
end