gpt4 book ai didi

twitter-bootstrap - 将 Bootstrap img 响应类添加到 wagtail 所见即所得编辑器

转载 作者:行者123 更新时间:2023-12-01 08:55:00 24 4
gpt4 key购买 nike

我正在尝试将正文图像插入页面时,将 Bootstrap 类“img-responsive”添加到图像标签中?

谁能告诉我如何做到这一点?

最佳答案

您可以通过图像格式做到这一点:

http://docs.wagtail.io/en/v0.8.5/core_components/pages/editing_api.html#image-formats-in-the-rich-text-editor

将图像插入富文本区域时通常会得到的“全宽”/“左对齐”/“右对齐”选项来自 Format 对象,它决定如何将图像引用转换为最终标记.因此,您需要将内置的 Format 对象替换为插入您的类名的对象。在您的应用中创建一个文件“image_formats.py”,其中包含以下内容:

from wagtail.wagtailimages.formats import Format, register_image_format, unregister_image_format

unregister_image_format('fullwidth')
register_image_format(Format('fullwidth', 'Full width', 'richtext-image full-width img-responsive', 'width-800'))

unregister_image_format('left')
register_image_format(Format('left', 'Left-aligned', 'richtext-image left img-responsive', 'width-500'))

unregister_image_format('right')
register_image_format(Format('right', 'Right-aligned', 'richtext-image right img-responsive', 'width-500'))

关于twitter-bootstrap - 将 Bootstrap img 响应类添加到 wagtail 所见即所得编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28745373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com