【问题标题】:Rails: Trix editor showing image and image size when caption is not specifiedRails:Trix 编辑器在未指定标题时显示图像和图像大小
【发布时间】:2020-09-08 00:21:12
【问题描述】:

我正在使用 Ubuntu 18 开发 Rails 6 应用程序。

我刚刚为 Trix 编辑器安装了 ActionText(所见即所得),这样我就可以将文本保存到管理员可以修改的数据库中,但是,当我添加图像 使用 Trix 编辑器 如果我没有为图像指定标题,它会显示 名称大小 图片的strong>作为标题

我只是想去掉字幕,只有我自己指定的时候才有字幕。

【问题讨论】:

    标签: ruby-on-rails trix actiontext


    【解决方案1】:

    后来我想出了怎么做。

    成功安装ActionText后:

    rails action_text:install
    

    并成功设置:

    // application.js
    require("trix")
    require("@rails/actiontext")
    
    // actiontext.scss
    @import "trix/dist/trix";
    

    从这里修改app/views/active_storage/blobs/_blob.html.erb中的这些代码行:

    <span class="attachment__name"><%= blob.filename %></span>
    <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
    

    到这里

    <span class="attachment__name"><% blob.filename %></span>
    <span class="attachment__size"><% number_to_human_size blob.byte_size %></span>
    

    即把这两行代码中的=符号去掉,这样图片的namesize就不会作为caption显示出来了未指定标题。

    就是这样。

    我希望这会有所帮助

    【讨论】:

      猜你喜欢
      • 2019-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 2019-12-06
      • 1970-01-01
      相关资源
      最近更新 更多