https://summernote.org/deep-d...
$('#summernote').summernote('insertImage', url, function ($image) { $image.css('width', $image.width() / 3); $image.attr('data-filename', 'retriever'); });
他官方提供的 API是這樣做。
只是有個怪異的問題
onImageUpload: function(files) { sendFile(files[0]); },
$content 是我的編輯器~
$content.summernote('insertImage', '/images/download.gif', function ($image) { console.log('preview: ' + fileData); $.ajax({ dataType: "json", type: "POST", url: "someurl", data: data, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', // timeout: timeoutVal, success: function(data){ $image.attr('src', data.url); } }); });
我是這樣使用他的 insertImage API
跟他上面寫的一樣
我可以成功利用 attr 替換已經上傳完成的圖片網址~這確定沒問題
只是假設上傳完成之後直接保存到數據庫時
即便他有成功替換 URL,他保存進去的網址卻還是 /images/download.gif
除非
上傳完網址之後,等他 attr 替換成功時
必須要在編輯器內「動一下」,比如說按個回車之類的
然後保存進去的數據庫會是正確的網址。。。。這是什麼詭異問題?github也沒有人回我。。。
忽然笑
相关分类