Module: Locomotive::ContentAssetsHelper

Defined in:
app/helpers/locomotive/content_assets_helper.rb

Instance Method Summary collapse

Instance Method Details

#asset_filename(asset) ⇒ Object



15
16
17
# File 'app/helpers/locomotive/content_assets_helper.rb', line 15

def asset_filename(asset)
  truncate(asset.source_filename, length: 28)
end

#asset_text(asset) ⇒ Object



19
20
21
22
23
# File 'app/helpers/locomotive/content_assets_helper.rb', line 19

def asset_text(asset)
  extname = truncate(asset.extname, length: 3)
  value = asset.content_type.to_s == 'other' ? extname : asset.content_type
  value.blank? ? '?' : value
end

#asset_with_thumbnail?(asset) ⇒ Boolean

Returns:



11
12
13
# File 'app/helpers/locomotive/content_assets_helper.rb', line 11

def asset_with_thumbnail?(asset)
  %w(image pdf).include?(asset.content_type)
end

#human_asset_size(asset) ⇒ Object



25
26
27
28
29
30
31
# File 'app/helpers/locomotive/content_assets_helper.rb', line 25

def human_asset_size(asset)
  if asset.image?
    "#{asset.width} X #{asset.height} px"
  else
    number_to_human_size(asset.size)
  end
end

#image_resize_form(content_asset) ⇒ Object



4
5
6
7
8
9
# File 'app/helpers/locomotive/content_assets_helper.rb', line 4

def image_resize_form(content_asset)
  Locomotive::ImageResizeForm.new(
    width:  content_asset.width,
    height: content_asset.height
  )
end