Froala编辑器图像绝对url路径配置

时间:2015-02-16 12:57:17

标签: url wysiwyg froala

我想知道在图片上传后图片来源是<img src="/uploads/image.jpg" />而不是<img src="http://example.com/uploads/image.jpg" />是否有任何选项?

我无法找到关于此内容的任何内容,并且我在localhost上添加了大量内容,当我将其上传到制作时,我必须手动更改链接

有什么建议吗?

3 个答案:

答案 0 :(得分:0)

插入图像时,也许可以尝试查找/替换。像这样:

$(".selector").on('editable.imageInserted', function (e, editor, img) {
var source = img.replace('www.host.com','');
$('.img_class').attr('src',source);
});

答案 1 :(得分:0)

我找到了froala https://github.com/froala/wysiwyg-editor/issues/445

的创建者回答的解决方案

由于

答案 2 :(得分:0)

最简单的方法是使用Froala的image server upload example并在链接的开头添加域

<?php
// Include the editor SDK.
require '/path/to/wysiwyg-editor-php-sdk-master/lib/FroalaEditor.php';

// Store the image.
try {
  $response = FroalaEditor_Image::upload('/path/to/upload/');
  $response->link = "https://www.example.com" . $response->link;
  echo stripslashes(json_encode($response));
}
catch (Exception $e) {
  http_response_code(404);
}
?>
相关问题