簡體   English   中英

回形針檢索樣式尺寸

[英]Paperclip retrieve styles dimentions

我使用Rails 4,並使用PaperClip將圖像附加到不同的模型。

我想檢索樣式尺寸,以便將其用作對用戶的提示,例如:

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

當我的模型Person看起來像這樣時:

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

可能嗎?

不確定這個問題,但我認為您可以通過以下方式獲得尺寸:

: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