CKEditor Carrierwave Cloudinary

前端 未结 4 1813
星月不相逢
星月不相逢 2021-01-06 10:52

I\'m trying to get CKEditor to work with Carrierwave and Cloudinary. So far, non-CKEditor enabled views with a regular file upload field are working perfectly with Carrierwa

4条回答
  •  忘掉有多难
    2021-01-06 11:18

    Checkout my comment here

    https://github.com/galetahub/ckeditor/issues/670#issuecomment-301218366

    # encoding: utf-8
    class CkeditorPictureUploader < CarrierWave::Uploader::Base
      include Ckeditor::Backend::CarrierWave
      include CarrierWave::MiniMagick
      include Cloudinary::CarrierWave
    
      process :extract_dimensions
    
      [:extract_content_type, :extract_size, :extract_dimensions].each do |method|
        define_method :"#{method}_with_cloudinary" do
          send :"#{method}_without_cloudinary" if self.file.is_a? CarrierWave::SanitizedFile
          {}
        end
        alias_method_chain method, :cloudinary
      end
    
      version :thumb do
        process :resize_to_fill => [118, 100]
      end
    
      version :content do
        process :resize_to_limit => [800, 800]
      end
    
      def extension_white_list
        Ckeditor.image_file_types
      end
    end
    

提交回复
热议问题