Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供图片样式的便利方法 #68

Merged
merged 2 commits into from
Oct 17, 2016
Merged

Conversation

bastengao
Copy link
Contributor

More to see #67

Usage:

class AvatarUploader < CarrierWave::Uploader::Base
  # 第一种 通过 array 配置图片样式
  qiniu_styles [:thumbnail, :large]
end

# 图片链接
user.avatar.url(:thumbnail)
# "http://..../avatar.jpg-thumbnail"

class AvatarUploader < CarrierWave::Uploader::Base
  # 第二种 通过 hash 配置图片样式
  qiniu_styles { thumbnail: "imageView2/0/w/200", large: "imageView2/0/w/800" }
end

user.avatar.url(:thumbnail)
# "http://..../avatar.jpg-thumbnail"
# 借助于qiniu可以直接在图片链接后面应用图片处理,这样图片样式可以不必事先添加就可以使用,尤其是在开发过程中比较方便
user.avatar.url(:thumbnail, inline: true) 
# "http://..../avatar.jpg?imageView2/0/w/200"


# 第三种 直接使用图片处理
user.avatar.url(style: "imageView2/0/w/200") 
# "http://..../avatar.jpg?imageView2/0/w/200"

@huobazi huobazi merged commit 98ca548 into huobazi:master Oct 17, 2016
@bastengao bastengao mentioned this pull request Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants