Sha256: 9caac740141aad91987e34b6e48ffe63d68722ab5b22e281c3a888ac80a0a648

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

module Neofiles
  class Engine < ::Rails::Engine
    config.autoload_paths << File.expand_path('../..', __FILE__)
    config.neofiles = ActiveSupport::OrderedOptions.new

    # mongo specific settings
    config.neofiles.mongo_files_collection    = 'files.files'
    config.neofiles.mongo_chunks_collection   = 'files.chunks'
    config.neofiles.mongo_client              = 'neofiles'
    config.neofiles.mongo_default_chunk_size  = 4.megabytes

    # image related settings
    config.neofiles.image_rotate_exif     = true # rotate image, if exif contains orientation info
    config.neofiles.image_clean_exif      = true # clean all exif fields on save
    config.neofiles.image_max_dimensions  = nil  # resize huge originals to meaningful size: [w, h], {width: w, height: h}, wh
    config.neofiles.image_max_crop_width  = 2000 # users can request resizing only up to this width
    config.neofiles.image_max_crop_height = 2000 # users can request resizing only up to this height

    config.neofiles.album_append_create_side = :right # picture when added is displayed on the right

    # default watermarker — redefine to set special watermarking logic
    # by default, watermark only images larger than 300x300 with watermark at the bottom center, taken from file
    # /app/assets/images/neofiles/watermark.png
    config.neofiles.watermarker = ->(image, no_watermark: false, watermark_width:, watermark_height:){
      if watermark_width < 300 || watermark_height < 300 || no_watermark
        return image.to_blob
      end

      image.composite(MiniMagick::Image.open(Rails.root.join('app', 'assets', 'images', 'neofiles', 'watermark.png'))) do |c|
        c.gravity 'south'
        c.geometry '200x+0+20'
      end.to_blob
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neofiles-1.3.2 lib/neofiles/engine.rb
neofiles-1.3.1 lib/neofiles/engine.rb
neofiles-1.3.0 lib/neofiles/engine.rb