![](/img/trans.png)
[英]Unable to resize image using image_tag (rails activestorage)
[英]ActionView::Template::Error (ActiveStorage::InvariableError) in image_tag for PDF file
我正在嘗試按變體顯示應用程序/pdf 文件預覽。 我安裝了 mutool 1.17 並在config/environments/development.rb
中指定了它的路徑。
config.active_storage.paths[:mutool] = '/usr/local/bin/mutool'
視圖是
<%= image_tag post.pdf.variant(resize_to_limit: [100, 100]) %>
我還應該怎么做才能顯示 PDF 文件預覽?
圖像文件(jpeg 和 png)顯示沒有任何問題。
我發現這是我的錯。 我監督了 Active Storage 文檔中的描述。 我應該使用 PDF 的預覽。 而已。
- <%= image_tag post.pdf.variant(resize_to_limit: [100, 100]) %>
+ <%= image_tag post.pdf.preview(resize_to_limit: [100, 100]) %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.