Module: Gluttonberg::AssetLibrary

Included in:
ApplicationHelper
Defined in:
app/helpers/gluttonberg/asset_library.rb

Instance Method Summary collapse

Instance Method Details

#asset_tag(asset, thumbnail_type = nil, options = {}) ⇒ Object



18
19
20
# File 'app/helpers/gluttonberg/asset_library.rb', line 18

def asset_tag(asset , thumbnail_type = nil, options = {} )
  asset_tag_v2(asset , options, thumbnail_type)
end

#asset_tag_v2(asset, options = {}, thumbnail_type = nil) ⇒ Object



22
23
24
25
26
27
# File 'app/helpers/gluttonberg/asset_library.rb', line 22

def asset_tag_v2(asset , options = {} , thumbnail_type = nil)
  if !asset.blank? && asset.category == "image"
    _prepare_options_for_asset_tag(asset , options , thumbnail_type)
    tag("img" , options)
  end
end

#asset_url(asset, opts = {}) ⇒ Object

nice and clean public url of assets



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/gluttonberg/asset_library.rb', line 5

def asset_url(asset , opts = {})
  url = ""
  if Rails.configuration.asset_storage == :s3
    url = asset.url
  else
    url = "http://#{request.host_with_port}/user_asset/#{asset.asset_hash[0..3]}/#{asset.id}"
    if opts[:thumb_name]
      url << "/#{opts[:thumb_name]}"
    end
  end
  url
end