Rails Trix Editor Anime Gif 顯示錯誤?
Rails
最近在這篇文章上傳了一個 GIF 的片段,發現在 Trix 編輯的時候是可以正常顯示的,但儲存之後顯示出來的卻只有第一禎的圖片。
翻譯年糕
將 blob.html.erb 裡面 image_tag 做個修改:
pre: <%= image_tag url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %> to: <%= image_tag url_for(blob.variant(loader: { n: -1 }, resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>
為什麼使用 loader: { n : 01} ?
Use *n* to select the number of pages to render. The default is 1. Pages are rendered in a vertical column. Set to -1 to mean "until the end of the document".
n 代表欲渲染的頁數,預設為 1,設為 -1 代表從頭渲染到尾。
![](/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6ImZmYTQ2ZGIxLTc0OTMtNDc3My1hM2JlLWNjZGE4NTA5OTJiYyIsInB1ciI6ImJsb2JfaWQifX0=--26915e8dc7001d45729da615201a2cf9faf7a106/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJsb2FkZXIiOnsibiI6LTF9LCJyZXNpemVfdG9fbGltaXQiOlsxMDI0LDc2OF19LCJwdXIiOiJ2YXJpYXRpb24ifX0=--589eab3cb219aa7003ba9652c21b627759a6f0bb/image.png)
感謝 Sean !
希望對你有幫助!~