Alright, this is a quick one to enhance paste and drag/drop image (I am in a hurry, I can't write a tut now):
This will solve your problem uploading the file to
IMGUR. For that your Imgur anon Client ID is required.
If you need to upload to other image host or even in your own site - you need to write a separate function.
1. First, download the attached SCE plugin file and upload to
jscripts/sceditor/plugins
folder.
2. Replace your
codebuttons
template with following:
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/sceditor/themes/{$theme['editortheme']}" type="text/css" media="all" />
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.bbcode.min.js?ver=1822"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/bbcodes_sceditor.js?ver=1823"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/plugins/undo.js?ver=1821"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/plugins/dragdrop.js?ver=1826"></script>
<script type="text/javascript">
var partialmode = {$mybb->settings['partialmode']},
imgurClientID = '<YOUR_IMGUR_CLIENT_ID_HERE>',
opt_editor = {
plugins: "undo, dragdrop",
format: "bbcode",
bbcodeTrim: true,
style: "{$mybb->asset_url}/jscripts/sceditor/styles/jquery.sceditor.{$theme['editortheme']}?ver=1823",
dragdrop: {
allowedTypes: ['image/jpeg', 'image/png'],
isAllowed: function (file) {
return true;
},
handlePaste: true,
handleFile: function (file, createPlaceholder) {
var placeholder = createPlaceholder();
imgurUpload(file).then(function (url) {
placeholder.insert('<img src=\'' + url + '\' />');
}).catch(function () {
placeholder.cancel();
});
}
},
rtl: {$lang->settings['rtl']},
locale: "mybblang",
width: "100%",
enablePasteFiltering: true,
autoUpdate: true,
emoticonsEnabled: {$emoticons_enabled},
emoticons: {
// Emoticons to be included in the dropdown
dropdown: {
{$dropdownsmilies}
},
// Emoticons to be included in the more section
more: {
{$moresmilies}
},
// Emoticons that are not shown in the dropdown but will still be converted. Can be used for things like aliases
hidden: {
{$hiddensmilies}
}
},
emoticonsCompat: true,
toolbar: "{$basic1}{$align}{$font}{$size}{$color}{$removeformat}{$basic2}image,{$email}{$link}|video{$emoticon}|{$list}{$code}quote|maximize,source",
};
{$editor_language}
$(function() {
$("#{$bind}").sceditor(opt_editor);
MyBBEditor = $("#{$bind}").sceditor("instance");
{$sourcemode}
});
function imgurUpload(file) {
var headers = new Headers({
'authorization': 'Client-ID '+ imgurClientID
});
var form = new FormData();
form.append('image', file);
return fetch('https://api.imgur.com/3/image', {
method: 'post',
headers: headers,
body: form
}).then(function (response) {
return response.json();
}).then(function (result) {
if (result.success) {
return result.data.link;
}
throw 'Upload error';
});
}
</script>
REMEMBER to replace
<YOUR_IMGUR_CLIENT_ID_HERE>
with your original Imgur Client ID.
Save the template.
Your editor will now support drag and drop image upload as well as paste from clipboard image upload.
Note: Its a tested code. Don't come up with "dat no work". Applied to the blank installation here for testing...
https://dev.eff.one