将引导程序img-responsive类添加到w W W W W W W WWYG编辑器中

Chr*_*rry 3 content-management-system twitter-bootstrap wagtail

我试图这样做,以便当身体图像插入页面时,bootstap类"img-responsive"被添加到图像标签?

谁能告诉我如何实现这一目标?

gas*_*man 8

您可以通过图像格式执行此操作:

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

将图像插入富文本区域时通常会得到的"全宽"/"左对齐"/"右对齐"选项来自格式对象,它决定了如何将图像引用转换为最终标记.因此,您需要将内置的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'))
Run Code Online (Sandbox Code Playgroud)