Sha256: 7f5308116da2dccf4bd676f3ff59cccbf93bab504e854e41014384ab8d4ecf28

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

module Smithy
  module AssetsHelper
    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

    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

    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
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
smithycms-0.8.1 app/helpers/smithy/assets_helper.rb
smithycms-0.7.3 app/helpers/smithy/assets_helper.rb
smithycms-0.7.2 app/helpers/smithy/assets_helper.rb
smithycms-0.7.1 app/helpers/smithy/assets_helper.rb
smithycms-0.7.0 app/helpers/smithy/assets_helper.rb
smithycms-0.6.10 app/helpers/smithy/assets_helper.rb
smithycms-0.6.9 app/helpers/smithy/assets_helper.rb
smithycms-0.6.7 app/helpers/smithy/assets_helper.rb
smithycms-0.6.6 app/helpers/smithy/assets_helper.rb
smithycms-0.6.5 app/helpers/smithy/assets_helper.rb
smithycms-0.6.4 app/helpers/smithy/assets_helper.rb
smithycms-0.6.3 app/helpers/smithy/assets_helper.rb
smithycms-0.6.2 app/helpers/smithy/assets_helper.rb
smithycms-0.6.1 app/helpers/smithy/assets_helper.rb
smithycms-0.6.0 app/helpers/smithy/assets_helper.rb