Module: Gluttonberg::Library::Config::ImageSizes

Extended by:
ActiveSupport::Concern
Defined in:
lib/gluttonberg/library/config/image_sizes.rb

Overview

Mixin which provides image sizes functionality to asset model

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DEFAULT_THUMBNAILS =

Default sizes used when thumbnailing an image.

{
  :small_thumb => {:label => "Small Thumb", :filename => "_thumb_small", :geometry => "360x268#" },
  :large_thumb => {:label => "Large Thumb", :filename => "_thumb_large", :geometry => "360x268>"},
  :backend_logo => {:label => "Backend Logo", :filename => "_backend_logo", :geometry => "1000x30"}
}
MAX_IMAGE_SIZE =

The default max image size. This can be overwritten on a per project basis via the rails configuration.

"2000x2000>"

Instance Method Summary collapse

Instance Method Details

#thumb_large_urlObject

Returns the public URL to the asset’s large thumbnail — relative to the domain.



58
59
60
# File 'lib/gluttonberg/library/config/image_sizes.rb', line 58

def thumb_large_url
  url_for(:large_thumb) if category.downcase == "image"
end

#thumb_small_urlObject

Returns the public URL to the asset’s small thumbnail — relative to the domain.



52
53
54
# File 'lib/gluttonberg/library/config/image_sizes.rb', line 52

def thumb_small_url
  url_for(:small_thumb) if category.downcase == "image"
end

#url_for(name = nil) ⇒ Object

InstanceMethods Returns the URL for the specified image size.



41
42
43
44
45
46
47
48
# File 'lib/gluttonberg/library/config/image_sizes.rb', line 41

def url_for(name=nil)
  if name.blank?
    url
  elsif self.class.sizes.has_key? name
    filename = self.class.sizes[name.to_sym][:filename]
    "#{asset_directory_public_url}/#{filename}.#{file_extension}"
  end
end