Last active
March 26, 2018 11:16
-
-
Save rudyryk/d39902318624780bcaa3 to your computer and use it in GitHub Desktop.
Plugin for Imperavi Redactor v10.x.x -- Insert image by link (feature is missing by default)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add image by link plugin for Imperavi Redactor v10.x.x | |
Updated: January 21, 2015 | |
Copyright (c) 2015, Alexey Kinev | |
License: The MIT License (MIT) http://opensource.org/licenses/MIT | |
Usage: | |
$('#redactor').redactor({ | |
imageUpload: false, | |
s3: false, | |
plugins: ['imagelink'] | |
}); | |
*/ | |
if (!RedactorPlugins) var RedactorPlugins = {}; | |
(function($) | |
{ | |
RedactorPlugins.imagelink = function() | |
{ | |
return { | |
getTemplate: function() | |
{ | |
return String() | |
+ '<section id="redactor-modal-imagelink-insert">' | |
+ '<label>' + this.lang.get('image_web_link') + '</label>' | |
+ '<input type="text" id="redactor-insert-imagelink">' | |
+ '</section>'; | |
}, | |
init: function() | |
{ | |
var button = this.button.addAfter('underline', 'image', this.lang.get('image')); | |
this.button.addCallback(button, this.imagelink.show); | |
}, | |
show: function() | |
{ | |
this.modal.addTemplate('imagelink', this.imagelink.getTemplate()); | |
this.modal.load('imagelink', this.lang.get('image'), 700); | |
this.modal.createCancelButton(); | |
var button = this.modal.createActionButton(this.lang.get('insert')); | |
button.on('click', this.imagelink.insert); | |
this.selection.save(); | |
this.modal.show(); | |
$('#redactor-insert-imagelink').focus(); | |
}, | |
insert: function() | |
{ | |
var data = $('#redactor-insert-imagelink').val(); | |
this.image.insert({filelink: data}, false); | |
} | |
}; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Redactor does this work with? I'm using 10.2.5 and when I click on the Image button, I'm just asked to "Drop file here or Browse". Shouldn't it ask for the link to the image instead?