我在我的Rails应用程序中使用Ckeditor作为我的富文本编辑器,我在使用它上传图像时遇到问题。对于文件上传支持,我使用的是Carrier Wave和Minimagick。 我没有收到任何错误,Ckeditor编辑器不会上传我的图像。除此之外,Ckeditor文本编辑器工作得非常好。
ckeditor_attachment_file_uploader.rb:
# encoding: utf-8
require 'carrierwave'
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/ckeditor/attachments/#{model.id}"
end
def extension_white_list
Ckeditor.attachment_file_types
end
end
ckeditor_image_uploader.rb:
class CkeditorPictureUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/ckeditor/pictures/#{model.id}"
end
process :extract_dimensions
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
image_uploader.rb:
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process :resize_to_fit => [50, 50]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
如果您需要查看任何代码,请与我们联系。