styles - 无论配置如何,Html 净化器都会删除图像样式,我该如何允许?
问题描述
我正在为 Laravel 使用https://github.com/mewebstudio/Purifier包,我遇到了一个问题,即无论我的配置如何,样式属性总是从输入中删除。这是我的配置
'HTML.Allowed' => 'font[color|style],h1[class|style],h2[class|style],h3[class|style],h4[class|style],h5[class|style],div[class|style],b,strong,i,em,a[href|title|class|style],ul,ol,li,p[style|class],br,span[style|class],img[style|width|height|alt|src|class],table[style|class],tbody[style|class],thead[style|class],tr[style|class],td[style|class],th[style|class]',
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,width',
这是我的输入:
<img src="http://mywebsite.deve/storage/1278/5f97ed8127418_5f8efd4d61487_image.png" class="img h-auto" style="width: 25%;" alt="" title="" role="">
这就是我在应用净化器的“清洁”后得到的
<img src="http://mywebsite.deve/storage/1278/5f97ed8127418_5f8efd4d61487_image.png" class="img h-auto" alt="">
我的配置错了吗?我已经被这个问题困扰了几个小时了,非常感谢任何帮助。
解决方案
感谢这篇文章https://github.com/mewebstudio/Purifier/issues/68我终于设法让它工作了。在配置中只需要在 'CSS.AllowedProperties'=> '...' 下添加 'CSS.MaxImgLength' => null
推荐阅读
- c# - 使用 NO 构造函数实例化类会导致“不包含采用 0 个参数的构造函数”错误
- database - ORM 不做 DDL 是真的吗?
- c# - 如何同时构建列表
在执行时 - python - 在检查多个列表并限制python中的结果时避免if条件
- node.js - 使用 UUID v4 生成会话 ID 是否安全?
- python - 在 Python 教程中获取属性错误:answer = input(question.prompt) AttributeError: 'str' object has no attribute 'prompt'
- mysql - 如何创建image-url而不是base-64(在express中使用summernote)?
- java - 如何将构造函数作为函数传递给泛型方法,然后在 stream().map() 操作中使用该构造函数?
- excel - 是否可以使用单元格索引引用将范围粘贴到范围中?
- sql - 使用单个 SQL 语句而不是循环插入 2 个表