paperclip一些使用技巧

一、关于styles设置,缩略图的切割策略
有两个符号,一个是‘#’,另一个是‘>’,说明如下:
[quote]trailing #, thumbnail will be centrally cropped, ensuring the requested dimensions.
trailing >, thumbnail will only be modified if it is currently larger requested dimensions. (i.e. the :small thumb for a 120×80 original image will be unchanged)[/quote]
还有其他的符号:
[url]http://www.imagemagick.org/Usage/resize/[/url]

另外如果仅仅写“120x”生成的图片会缩略成120像素宽的图,高度进行自动调整
如果写"x80"生成的图片会缩略成80像素高的图,宽度自动调整

二、批量处理图片的task任务
[quote]You can (re)generate your thumbnails en masse with Paperclip’s rake tasks. Using our example class above:

rake paperclip:refresh:thumbnails CLASS=User


or to refresh all of your defined styles in one go (:thumb, :small, :medium from the above example)

rake paperclip:refresh CLASS=User


and to refresh only missing styles:
a list of styles will be defined or updated in a file “/public/system/paperclip_attachments.yml”

rake paperclip:refresh:missing_styles


If you are using the gem required version of paperclip the rake tasks may not be auto-loaded, but you can copy them into your lib/tasks directory if needed.

If you need more manual control or have a lot of thumbnails and only want to process a few, you can use #reprocess! like so:

users_to_reprocess.each do |user|
user.photo.reprocess!
end

[/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<div v-else-if="per.dict_value === 'file_name'"> <el-tooltip placement="top" effect="dark" v-if="scope.row.download_time || scope.row.repair_download_time"> <div slot="content" > <span v-if="scope.row.repair_download_time">{{ parseTime(scope.row.repair_download_time,'{y}-{m}-{d} {h}:{i}:{s}') }}</span> <span v-else-if="scope.row.download_time">{{ parseTime(scope.row.download_time,'{y}-{m}-{d} {h}:{i}:{s}') }}</span> </div> <el-link v-if="scope.row.repair_file_id" :key="scope.row.repair_file_id" style="display: block;color: #67C23A" icon="el-icon-paperclip" @click="downloadOrderExcel(scope.row.repair_file_id, scope.row.order_no, scope.row.repair_file_name)" >{{ scope.row.repair_file_name }}</el-link> <el-link v-else-if="scope.row.file_id" :key="scope.row.file_id" style="display: block;color: #67C23A" icon="el-icon-paperclip" @click="downloadOrderExcel(scope.row.file_id, scope.row.order_no, scope.row.file_name)" >{{ scope.row[per.dict_value] }}</el-link> </el-tooltip> <div v-else> <el-link v-if="scope.row.repair_file_id" :key="scope.row.repair_file_id" style="display: block;" icon="el-icon-paperclip" @click="downloadOrderExcel(scope.row.repair_file_id, scope.row.order_no, scope.row.repair_file_name)" >{{ scope.row.repair_file_name }}</el-link> <el-link v-else-if="scope.row.file_id" :key="scope.row.file_id" style="display: block;" icon="el-icon-paperclip" @click="downloadOrderExcel(scope.row.file_id, scope.row.order_no, scope.row.file_name)" >{{ scope.row[per.dict_value] }}</el-link> </div> </div>优化这段代码用vue2.0
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值