将base64编码的src设置为插件jquery
我最近买了一个名为棒棒糖图像编辑器的插件来编辑我的图像,它可以很好地处理静态图像,但我面临着将其用于base64编码图像的问题 我基本上有一个画廊,用户可以上传图像,所以在上传阶段后,我有一个神奇的图标来打开编辑器并编辑图像这就是插件现在的工作方式 HTML将base64编码的src设置为插件jquery,jquery,Jquery,我最近买了一个名为棒棒糖图像编辑器的插件来编辑我的图像,它可以很好地处理静态图像,但我面临着将其用于base64编码图像的问题 我基本上有一个画廊,用户可以上传图像,所以在上传阶段后,我有一个神奇的图标来打开编辑器并编辑图像这就是插件现在的工作方式 HTML <div class="item-masonry box"><img src="images/demo-img.jpg"> <div class="but
<div class="item-masonry box"><img src="images/demo-img.jpg">
<div class="buttons"><a class="btn share-btn facebook" href="https://www.facebook.com/sharer/sharer.php?u="><i class="fa fa-facebook-official"></i></a><a class="btn share-btn pinterest" href="https://www.pinterest.com/pin/create/button/?url="><i class="fa fa-pinterest"></i></a>
<a
class="btn magic"><i class="fa fa-magic"></i></a>
</div>
</div>
现在我有了base64格式的图像,我想让插件接受base64格式的图像,这是我的html
html
<div class="images">
<input type="file" class="images-input" id="images_file_8"/>
<label for="images_file_8">
</label>
<div class="active-content">
<h5>Main Picture</h5>
</div>
<div class="div-count">
<h6 order="8">08</h6>
</div>
<div class="options">
<i class="fas fa-magic"></i>
<i class="fas fa-sync-alt"></i>
<i class="fas fa-times"></i>
</div>
<div class="progressbar"></div>
<div class="block-image">
<img src="data:image/jpeg,base64,/......."/>
</div>
</div>
但这是一个错误
Cannot read property 'src' of undefined
有没有一种方法可以传递base64编码的图像src?如果您已经使用jquery,您可以使用
img.attr('src')
而不是img[0]。src
我试着说url未定义!我认为与imageEditor
相关的东西可能现在正在获取静态图像url,所以我想可能是图像采用base64格式的问题
window.$(".magic").each(function () {
window.$(this).on("click", function () {
var img = $(this).parents("images").find("img");
imageEditor.open({
image_url: img[0].src
}, img[0]);
});
});
Cannot read property 'src' of undefined