在 laravel 中显示来自 db 的 summernote 中的图像
Display images inside summernote from db in laravel
我正在开发一个 laravel 项目,该项目应该从数据库中获取主页内容(HTML 内容)并将其显示在 Summernote 富文本编辑器中。 Summernote 很好地显示了我的 HTML 内容,但不显示图像。在查看 summernote 中显示的代码时,它已将 / 字符替换为“”。如果直接粘贴在 textarea 中而不是从 dB 中获取,则会显示相同的图像。我尝试了一些在网上和 Whosebug 上找到的解决方案,但它们对我不起作用。
$(document).ready(function() {
$('#summernote').summernote(
{
tabsize: 2,
height: 400
});
});
<form method="post">
<div>
<textarea class="summernote" id="summernote" name="editordata"><div class="row-iconbox our-support-block">
{!!$cms_home->homepage_content!!}
</textarea>
</div>
</form>
深入研究 /
被 ""
替换的字符,MySQL 在存储或更新图像地址时将 \
放在每个 "
之前从数据库加载 HTML 内容时找不到。
样本HTML
<img src="/storage/img/icon1.svg" height="100" width="100"/>
HTML 以 dB
存储后的内容
<img src=\"/storage/img/icon1.svg\" width=\"100\" height=\"100\" />
解决方案
1.检查 UTF 编码
在终端中打开 Mysql 并分别将 DATABASE_NAME、TABLE_NAME 替换为您的 db_name 和 table_name。
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "DATABASE_NAME" AND T.table_name = "TABLE_NAME";
2。如果编码不是utf8,alter database and table to utf8 encoding
see how to do this
3。将此代码添加到 HTML
中的 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
我正在开发一个 laravel 项目,该项目应该从数据库中获取主页内容(HTML 内容)并将其显示在 Summernote 富文本编辑器中。 Summernote 很好地显示了我的 HTML 内容,但不显示图像。在查看 summernote 中显示的代码时,它已将 / 字符替换为“”。如果直接粘贴在 textarea 中而不是从 dB 中获取,则会显示相同的图像。我尝试了一些在网上和 Whosebug 上找到的解决方案,但它们对我不起作用。
$(document).ready(function() {
$('#summernote').summernote(
{
tabsize: 2,
height: 400
});
});
<form method="post">
<div>
<textarea class="summernote" id="summernote" name="editordata"><div class="row-iconbox our-support-block">
{!!$cms_home->homepage_content!!}
</textarea>
</div>
</form>
深入研究 /
被 ""
替换的字符,MySQL 在存储或更新图像地址时将 \
放在每个 "
之前从数据库加载 HTML 内容时找不到。
样本HTML
<img src="/storage/img/icon1.svg" height="100" width="100"/>
HTML 以 dB
存储后的内容<img src=\"/storage/img/icon1.svg\" width=\"100\" height=\"100\" />
解决方案
1.检查 UTF 编码
在终端中打开 Mysql 并分别将 DATABASE_NAME、TABLE_NAME 替换为您的 db_name 和 table_name。
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "DATABASE_NAME" AND T.table_name = "TABLE_NAME";
2。如果编码不是utf8,alter database and table to utf8 encoding
see how to do this
3。将此代码添加到 HTML
中的<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">