Sha256: cf16c56560839246b23d60558a19a8bca88b045afe380d6aa63260685562b685
Contents?: true
Size: 1.42 KB
Versions: 27
Compression:
Stored size: 1.42 KB
Contents
module Alchemy::Custom::Model::ElFinder module Volumes class AlchemyImages < AlchemyFile def initialize(options = {root: '/images', name: acm_t("volume",scope:'elfinder.alchemy_images'), id: 'alchemy_library_images', url: '/'}) super end def files(target = '.') super(root_path) end def decode(hash) super do |path| Paths::Image.new(@root, path, volume: self) end end def upload(target, upload) super do |file| img = ::Alchemy::Picture.new( image_file: file ) img.name = img.humanized_name img.save! root_path.build_file_path(img) end end def search(type:, q:) super do search_query_build(klass: ::Alchemy::Picture, type: type, q: q, mime_attribute: :file_mime_type) end end def disabled_commands super + ['rm'] end def duplicate(t) new_path = Rails.root.join('tmp', "copy_#{File.basename(t.name)}") ::FileUtils.cp(t.file.path, new_path) img = ::Alchemy::Picture.new( image_file: new_path ) img.name = img.humanized_name img.save root_path.build_file_path(img) end def duplicable?(target) true end def root_path Paths::Images.new(@root, '.', volume: self) end end end end
Version data entries
27 entries across 27 versions & 1 rubygems