简体   繁体   English

回形针检索样式尺寸

[英]Paperclip retrieve styles dimentions

I work with Rails 4 and use PaperClip to attach images to different models. 我使用Rails 4,并使用PaperClip将图像附加到不同的模型。

I would like to retrieve styles dimensions in order to use them as a hint for user, something like: 我想检索样式尺寸,以便将其用作对用户的提示,例如:

<%= t('image_dimensions_hint', :dimensions => Person.avatar.standard') %>

When my model Person looks like that: 当我的模型Person看起来像这样时:

has_attached_file :avatar,
 :styles => { 
   :standard => "150x150>",
   :small => "50x50>>",
}

Is it possible? 可能吗?

不确定这个问题,但我认为您可以通过以下方式获得尺寸:

:dimensions => Paperclip::Geometry.from_file(file.queued_for_write[:original].path)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM