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

Conversation

Projects
None yet
3 participants
@bastengao
Contributor

bastengao commented Oct 17, 2016

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 referenced this pull request Oct 24, 2016

Merged

重构了图片样式 #70

@hpyhacking

This comment has been minimized.

Show comment
Hide comment
@hpyhacking

hpyhacking Dec 5, 2016

让使用 Rails 4.0.x 版本的人情何以堪?

hpyhacking commented on lib/carrierwave/qiniu/style.rb in fc67e70 Dec 5, 2016

让使用 Rails 4.0.x 版本的人情何以堪?

This comment has been minimized.

Show comment
Hide comment
@bastengao

bastengao Dec 6, 2016

Contributor

@hpyhacking 你的意思是 Rails 4.0.x 的 ActiveSupport::Concern 写法不是 class_method 而是

module ClassMethod do
  ...
end
Contributor

bastengao replied Dec 6, 2016

@hpyhacking 你的意思是 Rails 4.0.x 的 ActiveSupport::Concern 写法不是 class_method 而是

module ClassMethod do
  ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment