Sha256: f05ad86cf51f00ba532279217488369233c7f14076d22a6c0fe5cd4f8309ef9a

Contents?: true

Size: 1.12 KB

Versions: 42

Compression:

Stored size: 1.12 KB

Contents

module Locomotive
  module API
    module Entities

      class ContentAssetEntity < BaseEntity

        expose :content_type, :width, :height, :vignette_url, :alternative_vignette_url, :checksum

        expose :filename do |content_asset, _|
          truncate(content_asset.source_filename, length: 28)
        end

        expose :short_name do |content_asset, _|
          truncate(content_asset.name, length: 15)
        end

        expose :extname, format_with: :truncate_to_3

        expose :full_filename do |content_asset, _|
          content_asset.source_filename
        end

        expose :content_type_text do |content_asset, _|
         value = content_asset.content_type.to_s == 'other' ? content_asset.extname : content_asset.content_type
         value.blank? ? '?' : value
        end

        expose :with_thumbnail do |content_asset, _|
         %w(image pdf).include?(content_asset.content_type)
        end

        expose :raw_size do |content_asset, _|
         content_asset.size
        end

        expose :url do |content_asset, _|
          content_asset.source.url
        end

      end

    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.2.0.alpha1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.1.1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.1.0 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.1.0.rc1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.3 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.2 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.0 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.0.rc0 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.0.alpha3 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.4.1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.0.alpha2 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-4.0.0.alpha1 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.4.0 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.3.0 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.3.0.rc3 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.3.0.rc2 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.1.2 app/api/locomotive/api/entities/content_asset_entity.rb
locomotivecms-3.2.1 app/api/locomotive/api/entities/content_asset_entity.rb