class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def default_url
ActionController::Base.helpers.asset_path("fallback/" + [main, "default.png"].compact.join('_'))
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fit => [50, 50]
end
version :main do
process :auto_orient
process :resize_to_fit => [300, 360]
end
def auto_orient
manipulate! do |img|
img = img.auto_orient
end
end
end
내 기본 이미지 앱/자산/이미지/대체에 업로드 한/주 /이 DEFAULT_URL에 의해 설명 된 표준 자산 파이프 라인을 따르고레일 4 - CarrierWave 자산 이미지와 함께 작동하지 DEFAULT_URL
을 default.png 캐리어 웨이브 젬. 나에게 오류는 아니지만보기에 깨진 이미지 아이콘 만 기본 이미지가 표시되지 않습니다. 그러나 유효한 업로드가있는 경우 업로드를 제대로 표시하므로 : 엄지 손가락과 : 메인 프로세스가 작동합니다. 깨고있는 유일한 부분은 default_url이며, 나는 그 이유를 모른다. 레일 4 btw를 사용하고 있습니다. 어떤 생각/아이디어?
감사합니다. 이 업로드되어 깨진 기본 URL이
<div class="img-container">
<%= image_tag @user.image_url(:main).to_s %>
</div>
png의 크기가 중요합니까? 그렇다면 300x400입니다. – camdixon