Sha256: 13b1d99912d5a01d4621cc9585e7727906fbc7921e391c0d2167e9a2028ed39a

Contents?: true

Size: 1.02 KB

Versions: 47

Compression:

Stored size: 1.02 KB

Contents

module Tenon
  module AssetHelper
    def asset_icon(asset)
      if asset.attachment.exists?(:thumbnail)
        i = image_tag(asset.attachment.url(:thumbnail))
      else
        i = image_tag(default_asset_thumbnail(asset))
      end
      asset_icon_link(asset, i)
    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 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' => 'Edit Asset'
      }
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
tenon-1.0.56 app/helpers/tenon/asset_helper.rb
tenon-1.0.55 app/helpers/tenon/asset_helper.rb
tenon-1.0.54 app/helpers/tenon/asset_helper.rb
tenon-1.0.53 app/helpers/tenon/asset_helper.rb
tenon-1.0.52 app/helpers/tenon/asset_helper.rb
tenon-1.0.51 app/helpers/tenon/asset_helper.rb
tenon-1.0.50 app/helpers/tenon/asset_helper.rb
tenon-1.0.49 app/helpers/tenon/asset_helper.rb
tenon-1.0.48 app/helpers/tenon/asset_helper.rb
tenon-1.0.47 app/helpers/tenon/asset_helper.rb
tenon-1.0.46 app/helpers/tenon/asset_helper.rb
tenon-1.0.45 app/helpers/tenon/asset_helper.rb
tenon-1.0.44 app/helpers/tenon/asset_helper.rb
tenon-1.0.43 app/helpers/tenon/asset_helper.rb
tenon-1.0.42 app/helpers/tenon/asset_helper.rb
tenon-1.0.41 app/helpers/tenon/asset_helper.rb
tenon-1.0.40 app/helpers/tenon/asset_helper.rb
tenon-1.0.39 app/helpers/tenon/asset_helper.rb
tenon-1.0.38 app/helpers/tenon/asset_helper.rb
tenon-1.0.37 app/helpers/tenon/asset_helper.rb