Sha256: f0b256b35186f6e25de13f105cbeae3bf124844892b7e6d6b4a0780589d6aaf5

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

module Locomotive
  module Concerns
    module Asset
      module Vignette

        def vignette_url
          if self.image?
            # In some case (like an invalid extension) the height, width can be nill
            # In that case we should directly return the url
            if self.width && self.height && self.width < 85 && self.height < 85
              self.source.url
            else
              Locomotive::Dragonfly.resize_url(self.source, '85x85#', self.updated_at.to_i)
            end
          elsif self.pdf?
            Locomotive::Dragonfly.thumbnail_pdf(self.source, '85x85#', self.updated_at.to_i)
          end
        end

        def alternative_vignette_url
          format = if self.image? && self.width && self.height
            '190x120>'
          elsif self.pdf?
            '190x120#'
          end

          Locomotive::Dragonfly.thumbnail_pdf(self.source, format, self.updated_at.to_i) if format
        end

        def big_vignette_url
          format = if self.image? || self.pdf?
            '200x200#'
          end

          Locomotive::Dragonfly.thumbnail_pdf(self.source, format, self.updated_at.to_i) if format
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/models/locomotive/concerns/asset/vignette.rb
locomotivecms-4.2.0.alpha1 app/models/locomotive/concerns/asset/vignette.rb
locomotivecms-4.1.1 app/models/locomotive/concerns/asset/vignette.rb
locomotivecms-4.1.0 app/models/locomotive/concerns/asset/vignette.rb
locomotivecms-4.1.0.rc1 app/models/locomotive/concerns/asset/vignette.rb