Sha256: 338886a1e6adf39ad6f302aabf0fd8561560a98712b31cc97cdd53f0be7a3773
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
module Tenon module AssetHelper 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 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 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 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 def default_asset_thumbnail(asset) if asset && asset.attachment_content_type.match('video') 'tenon/thumb-video.png' else 'tenon/thumb-doc.png' end end private def crop_options(asset) { class: 'asset-crop', data: { 'asset-id' => asset.id, 'post-crop-handler' => 'Tenon.features.AssetListPostCropHandler' } } end def default_options { 'data-modal-remote' => true, 'data-modal-title' => t('tenon.assets.edit_asset') } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tenon-1.1.8 | app/helpers/tenon/asset_helper.rb |
tenon-1.1.7 | app/helpers/tenon/asset_helper.rb |
tenon-1.1.6 | app/helpers/tenon/asset_helper.rb |
tenon-1.1.5 | app/helpers/tenon/asset_helper.rb |