我正在使用操作文本和 Trix 富编辑器将应用程序迁移到 Rails 6.1.4.4。在后端,Trix 将上传的文件保存到活动存储 blob 并完美地显示在编辑器中。
但是,当我尝试在没有 Trix 的情况下在前端显示时,上传的图像没有按预期显示。
下面是我的blob视图
<!-- active_storage/blobs/_blob.html.erb -->
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<% blog_url = blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 600, 400 ] : [ 400, 400 ]).processed.service_url %>
<%= lazy_image(src: blog_url, alt: '', width: '400', height: '400') %>
<% end %>
<figcaption class="attachment__caption">
<% if caption = blob.try(:caption) %>
<%= caption %>
<% else %>
<span class="attachment__name"><%= blob.filename %></span>
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
<% end %>
</figcaption>
</figure>
我还尝试了其他一些 html 标签,似乎一些 html 标签被剥离了,只保留标签内容而不是完整的语义标签。
我的 blob 渲染内容会被清除吗?我是否缺少任何配置以使显示器在没有 trix 编辑器的情况下工作?