Admin: WYSIWYG: Add configuration setting 'ck_editor_block_image_copy_paste' to block image copy & paste creating a base64 image in HTML source (and ending up filling the database) - refs #3322

pull/3495/head
Angel Cubas 5 years ago committed by GitHub
parent 06ea06e32e
commit 62f646c403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      main/inc/lib/javascript/ckeditor/plugins/blockimagepaste/plugin.js
  2. 4
      main/install/configuration.dist.php
  3. 1
      main/template/default/layout/main.js.tpl
  4. 4
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php

@ -0,0 +1,23 @@
(function () {
// register plugin
CKEDITOR.plugins.add('blockimagepaste', {
init: function (editor) {
editor.on( 'paste', function(e) {
var html = e.data.dataValue;
if (!html) return;
// Replace data: images in Firefox and upload them
e.data.dataValue = html.replace( /<img( [^>]*)?>/gi, function( img ) {
alert('Pasting images directly into the editor is not allowed. ');
return '';
});
});
}
});
})();

@ -1604,6 +1604,10 @@ $_configuration['auth_password_links'] = [
// Allow teachers and admins to see students as friends on social network
// $_configuration['social_make_teachers_friend_all'] = false;
// Prevent the use of images copy-paste as base64 in the editor to avoid
// filling the database with images
//$_configuration['ck_editor_block_image_copy_paste'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -585,6 +585,7 @@ if (typeof CKEDITOR !== 'undefined') {
'asciimath',
'asciisvg',
'audio',
'blockimagepaste',
'ckeditor_wiris',
'dialogui',
'glossary',

@ -146,6 +146,10 @@ class Basic extends Toolbar
$plugins[] = 'ckeditor_vimeo_embed';
}
if (api_get_configuration_value('ck_editor_block_image_copy_paste')) {
$plugins[] = 'blockimagepaste';
}
$this->defaultPlugins = array_unique(array_merge($this->defaultPlugins, $plugins));
parent::__construct($toolbar, $config, $prefix);

Loading…
Cancel
Save