Class: Carousel

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/carousel.rb

Overview

Rails engine for the Carousel plug-in.

Class Method Summary collapse

Class Method Details

.paperclip_options(additional = {}) ⇒ Hash

Returns options for the `has_attached_file` method to include a Carousel-compatible style. You can override any options as necessary using `additional`.

Examples:

Basic example with additional styles

has_attached_file Carousel.paperclip_options(
  styles: {
    another: '512x512'
  }
)

Overriding carousel border radius

has_attached_file Carousel.paperclip_options(
  styles: { carousel: { border_radius: 5 } }
)

Parameters:

  • additional (Hash) (defaults to: {})

    Additional styles or other Paperclip options to pass to `has_attached_file`, or overrides for the options this method adds (see the source).

Returns:

  • (Hash)

    Options to pass to `has_attached_file`.


28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/carousel.rb', line 28

def self.paperclip_options(additional={})
  additional[:processors] = Array.wrap(additional[:processors])
  additional[:processors] << :round_corners

  additional[:styles]                            ||= {}
  additional[:styles][:carousel]                 ||= {}
  additional[:styles][:carousel][:geometry]      ||= '140x100#'
  additional[:styles][:carousel][:format]        ||= :png
  additional[:styles][:carousel][:border_radius] ||= 8

  additional
end