<%= f.input :avatar, label: "图标:", as: :file %>
$("#production_avatar").removeClass('file').fileinput({
overwriteInitial: true,
maxFileSize: 1500,
showClose: false,
showCaption: false,
zoomIcon: false,
browseLabel: '',
removeLabel: '',
browseIcon: '<i class="glyphicon glyphicon-folder-open"></i>',
removeIcon: '<i class="glyphicon glyphicon-remove"></i>',
removeTitle: '取消',
elErrorContainer: false,
msgErrorClass: 'alert alert-block alert-danger',
defaultPreviewContent: '<img src="/assets/default_avatar.jpg" alt="" style="width:160px">',
layoutTemplates: {main2: '{preview} {remove} {browse}', footer: ''},
allowedFileExtensions: ["jpg", "jpeg", "png", "gif"],
<% if @production && [email protected]? %>
initialPreview: [ //预览图片的设置
'<img src="<%= @production.avatar %>" class="file-preview-image" alt="" style="width:160px">',
]
<% end %>
}).on('fileerror', function (event, data, msg) {
alert('请选择图片文件!')
});
图片上传时预浏览设置
猜你喜欢
转载自hhg08.iteye.com/blog/2353522
今日推荐
周排行