I am using Responsive Filemanager with tinyMce 4.6.5 in Codeigniter.
After the page is loaded, if I try to insert an image from the existing ones, the thumbnails are not displayed (example in the picture).
My Responsive Filemanager configuration:
'base_url' => ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && ! in_array(strtolower($_SERVER['HTTPS']), array( 'off', 'no' ))) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'],
'upload_dir' => '/testsite/uploads/tinyMce/thumbs/',
'current_path' => '../../uploads/tinyMce/thumbs/',
'thumbs_base_path' => '../../uploads/tinyMce/thumbs/', //opens in filemanager
And tinyMce configuration:
tinymce.init({
selector: selector,
height: 200,
width: 700,
theme: 'modern',
skin:'lightgray',
plugins: [
'advlist autolink lists charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor textpattern imagetools toc responsivefilemanager'
],
filemanager_title:"Responsive Filemanager",
external_filemanager_path: siteURL + "scripts/filemanager/",
external_plugins: { "filemanager" : siteURL + "scripts/filemanager/plugin.min.js"},
toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'print preview media | forecolor backcolor emoticons | help',
image_advtab: true,
templates: [
{ title: 'Test template 1', content: 'Test 1' },
{ title: 'Test template 2', content: 'Test 2' }
]
});
If I inspect the image container, this is the html:
<img class=" lazy-loaded" data-original="../../uploads/tinyMce/thumbs/doggo.jpg" src="data:image/png;base64...">
And after pressing the refresh button from Responsive filemanager, it changes to this:
<img class=" lazy-loaded" data-original="../../uploads/tinyMce/thumbs/doggo.jpg" src="../../uploads/tinyMce/thumbs/doggo.jpg" style="display: inline;">
The thumbnail is displayed if I press on 'Preview'.
Thanks in advance :)
try to edit a file from filemanager folder that name is dialog.php
Type search "img" and you will find div with class img-precontainer.
Then you will see "data-src". You must change it to be "src". Hope it works.
here is the link for the code/example https://gist.github.com/cloudsnight/f44103499e9bb5b782efea7e80b4c9a6
here is the link of complete example from me :
https://github.com/cloudsnight/testplugins.git
Related
After integration, I used to create a template and save the HTML source code. After I view that HTML code it shows the below as in the attached screenshot.
Inside that editor shows like the below-attached screenshot:
Here is my code
var tinyconfig = {
skin: 'oxide-dark',
inline: true,
menubar: false,
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : '',
inline_boundaries: false,
relative_urls: false,
convert_urls: false,
remove_script_host : false,
valid_elements : '*[*],meta[*]',
valid_children: '+h1[div],+h2[div],+h3[div],+h4[div],+h5[div],+h6[div],+a[div]',
plugins: 'image link textcolor lists autolink',
//toolbar: 'undo redo | bold italic underline | fontselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent',
// toolbar: [
// 'undo redo | bold italic underline | fontselect fontsizeselect | link | menuDateButton',
// 'forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent'
// ],
toolbar:false,
external_filemanager_path:'{{ url('/') }}'.replace('/index.php','')+"/filemanager2/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : '{{ url('/') }}'.replace('/index.php','')+"/filemanager2/plugin.min.js"},
setup: function (editor) {
/* Menu button that has a simple "insert date" menu item, and a submenu containing other formats. */
/* Clicking the first menu item or one of the submenu items inserts the date in the selected format. */
editor.ui.registry.addMenuButton('menuDateButton', {
text: getI18n('editor.insert_tag'),
fetch: function (callback) {
var items = [];
thisEditor.tags.forEach(function(tag) {
if ( tag.type == 'label') {
items.push({
type: 'menuitem',
text: tag.tag.replace("{", "").replace("}", ""),
onAction: function (_) {
if (tag.text) {
editor.insertContent(tag.text);
} else {
editor.insertContent(tag.tag);
}
}
});
}
});
callback(items);
}
});
}
};
In the ckeditor (plugin.js) I have this code below.
CKEDITOR.plugins.add( 'beforeafter', {
requires: 'widget',
icons: 'beforeafter',
init: function( editor ) {
editor.widgets.add( 'beforeafter', {
button: 'beforeafter',
template:
'<div class="ba-slider-element">' +
'<div class="ba-slider">' +
'<div class="resize">' +
'<div class="handle">' +
'</div>',
dialog: 'beforeafterDialog',
upcast: function( element ) {
return element.name == 'div' && element.hasClass( 'ba-slider' );
}
} );
// Define an editor command that opens our dialog window.
editor.addCommand( 'beforeafter', new CKEDITOR.dialogCommand( 'beforeafterDialog' ) );
// Create a toolbar button that executes the above command.
editor.ui.addButton( 'beforeafter', {
// The text part of the button (if available) and the tooltip.
label: 'Insert A Before And After Image',
// The command to execute on click.
command: 'beforeafter',
// The button placement in the toolbar (toolbar group name).
toolbar: 'insert'
});
// Register our dialog file -- this.path is the plugin folder path.
CKEDITOR.dialog.add( 'beforeafterDialog', this.path + 'dialogs/beforeafter.js' );
}
});
In the dialog file (beforeafter.js) I have this code below.
CKEDITOR.dialog.add( 'beforeafterDialog', function( editor ) {
return {
title: 'Before and After Image Tool',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Basic Settings',
// The tab content.
elements: [
{
type: 'text',
id: 'beforeimage',
label: 'paste your BEFORE image URL below',
validate: CKEDITOR.dialog.validate.notEmpty( "Please add a URL in the Before image field." )
},
{
type: 'text',
id: 'afterimage',
label: 'paste your AFTER image URL below',
validate: CKEDITOR.dialog.validate.notEmpty( "Please add a URL in the After image field." )
}
]
},
],
onOk: function() {
var dialog = this;
var result = editor.document.createElement('div');
result.setHtml("<div class=\"ba-slider-element\">\n" +
"<div class=\"ba-slider\">\n" +
"<img src=\"" + dialog.getValueOf( 'tab-basic', 'beforeimage' ) + "\" alt=\"\">\n" +
"<div overlay-lable=\"Before\" class=\"before-lable-1\">\n" +
"<div overlay-lable=\"Before\" class=\"before-lable-2\">\n" +
"<div class=\"resize\">\n" +
"<img src=\"" + dialog.getValueOf( 'tab-basic', 'afterimage' ) + "\" alt=\"\">\n" +
"<div overlay-lable=\"After\" class=\"after-lable-1\">\n" +
"</div>\n" +
"<div overlay-lable=\"After\" class=\"after-lable-2\"></div></div>\n" +
"<div class=\"handle\">\n" +
"</div>");
editor.insertElement( result );
}
};
});
In the ckeditor posting edit window, when I click the source button to view the source, this is the code that is generated below.
<div>
<div class="ba-slider-element">
<div class="ba-slider">
<img alt="" src="https://pepsized.com/wp-content/uploads/2018/09/beerslider/demo-assets/images/man-hold-beer.jpg">
<div overlay-lable="Before" class="before-lable-1">
<div overlay-lable="Before" class="before-lable-2">
<div class="resize">
<img alt="" src="https://pepsized.com/wp-content/uploads/2018/09/beerslider/demo-assets/images/man-hold-beer-after1logo.jpg">
<div overlay-lable="After" class="after-lable-1">
</div>
<div overlay-lable="After" class="after-lable-2">
</div>
</div>
<div class="handle">
</div>
</div>
</div>
</div>
</div>
The slider works fine but I am not able to edit the URL fields.
When I double click the slider to edit it the dialog window will pop up with an empty URL fields.
ckeditor diolog
What I need help with is.
1. I need the element to highlight in yellow and blue when I hover over the area
2. When I double click to edit, the dialog fields should show the previous inputted URL.
3. How would be able to preview the slider wile in edit mode. the slider use jquery script.
Your help will be truly appreciated.
I am developing my own image manager, until now I have reached to open the pop-up and list my images, but after this I have no idea how to get the URL of the image to insert in tiny mce
Here's is my source code:
$(document).ready(function() {
$('#txapublication').tinymce({
toolbar: 'styleselect | bold underline italic | alignleft aligncenter alignright alignjustify | bullist numlist | link image | media | forecolor backcolor',
plugins: [
'advlist image autolink link lists charmap preview',
'searchreplace wordcount code media',
'save textcolor'
],
menubar: false,
language: 'es',
file_browser_callback: function(field_name, url, type, win) {
win.document.getElementById(field_name).value = 'my browser value';
tinymce.activeEditor.windowManager.open({
title: 'Browse Image',
file: "<? echo PUBLIC_PATH ?>" + 'account/selimgsblog',
width: 450,
height: 305,
resizable: "no",
inline: "yes",
close_previous: "no",
buttons: [{
text: 'Insert',
classes: 'widget btn primary first abs-layout-item',
disabled: true,
onclick: 'close'
}, {
text: 'Close',
onclick: 'close',
window: win,
input: field_name
}]
});
}
});
});
Here is my source to list the images, these images come from a method in a controller
<?foreach($imagenes as $img):?>
<img src="<? echo PUBLIC_PATH.$img->path.$img->name?>" width="80" height="80"/>
<?endforeach;?>
I am using tiny mce 4.0.6
You can try:
In buttons.js
(function() {
tinymce.PluginManager.add('my_mce_button', function( editor, url ) {
editor.addButton( 'my_mce_button', {
icon: 'my-mce-icon',
onclick: function() {
editor.insertContent('[shortcode name="" title=""]');
}
});
});
})();
Here need to use buttons as background like this in functions.php:
function my_shortcodes_mce_css() { ?>
<style type="text/css" >
.mce-ico.mce-i-my-mce-icon {
background:url(http://prowpexpert.com/wp-content/uploads/2014/05/favicon-1.ico);
}
</style>
<?php
}
add_action( 'admin_enqueue_scripts', 'my_shortcodes_mce_css' );
You can get help from here about wp tiny mce buttons: http://prowpexpert.com/dynamic-tab-html-wp/
I have to display a drop down list in tinymce. I googled to find any tutorial or any good example but I just found that code:
// Adds a menu to the currently active editor instance
var dm = tinyMCE.activeEditor.controlManager.createDropMenu('somemenu');
// Add some menu items
dm.add({title : 'Menu 1', onclick : function() {
alert('Item 1 was clicked.');
}});
dm.add({title : 'Menu 2', onclick : function() {
alert('Item 2 was clicked.');
}});
// Adds a submenu
var sub1 = dm.addMenu({title : 'Menu 3'});
sub1.add({title : 'Menu 1.1', onclick : function() {
alert('Item 1.1 was clicked.');
}});
// Adds a horizontal separator
sub1.addSeparator();
sub1.add({title : 'Menu 1.2', onclick : function() {
alert('Item 1.2 was clicked.');
}});
// Adds a submenu to the submenu
var sub2 = sub1.addMenu({title : 'Menu 1.3'});
// Adds items to the sub sub menu
sub2.add({title : 'Menu 1.3.1', onclick : function() {
alert('Item 1.3.1 was clicked.');
}});
sub2.add({title : 'Menu 1.3.2', onclick : function() {
alert('Item 1.3.2 was clicked.');
}});
dm.add({title : 'Menu 4', onclick : function() {
alert('Item 3 was clicked.');
}});
// Display the menu at position 100, 100
dm.showMenu(100, 100);
This code seems to create a drop down list but I don't know where to put this code or how to use it to display custom drop down list.
Kindly somebody help me in adding custom drop down list in tinyMCE.
var myListItems = ['Item1', 'Item2', 'Item3', 'Item4', 'Item5', 'Item6', 'Item7',
'Item8', 'Item9', 'Item10', 'Item11'];
tinymce.PluginManager.add('mypluginname', function (editor) {
var menuItems = [];
tinymce.each(myListItems, function (myListItemName) {
menuItems.push({
text: myListItemName,
onclick: function () {
editor.insertContent(myListItemName);
}
});
});
editor.addButton('mypluginname', {
type: 'menubutton',
text: 'My Plugin Name',
icon: 'code',
menu: menuItems
});
editor.addMenuItem('mypluginnameDropDownMenu', {
icon: 'code',
text: 'My Plugin Name',
menu: menuItems,
context: 'insert',
prependToContext: true
});
});
Then add to your list of plugin when you initialize your editor:
$('#myTesxtArea').tinymce({
theme: "modern",
convert_urls: false,
height: 100,
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime nonbreaking save table contextmenu directionality",
"paste textcolor","mypluginname"
],
toolbar1: "undo redo | forecolor backcolor | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
image_advtab: true
});
Here's how panel button with dropdown looks like:
First, register the plugin:
var myListItems = ['Item1','Item2'];
tinymce.PluginManager.add('myNewPluginName', function(editor) {
var menuItems = [];
tinymce.each(myListItems, function(myListItemName) {
menuItems.push({
text: myListItemName,
onclick: function() {
editor.insertContent(myListItemName);
}
});
});
editor.addMenuItem('insertValueOfMyNewDropdown', {
icon: 'date',
text: 'Do something with this new dropdown',
menu: menuItems,
context: 'insert'
});
});
Then add to your list of plugin when you initialize your editor:
$('#myTesxtArea').tinymce({
theme: "modern",
convert_urls: false,
height: 100,
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime nonbreaking save table contextmenu directionality",
"myNewPluginName paste textcolor"
],
toolbar1: "undo redo | forecolor backcolor | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
image_advtab: true
});
Here is TinyMCE's documentation for creating a plugin http://www.tinymce.com/wiki.php/TinyMCE3x:Creating_a_plugin. I would start with that just to learn how plugins work. Then to get a better feel for creating a dropdown menu look at the contextmenu plugin. Copy it, and modify it to meet your needs.
In default.php
JHTML::_('behavior.tooltip');
<a href="#">
<?php echo JHTML::tooltip('test test test', 'title', '', 'title');?></a>
But it can't show tooltip ? How to fix it ?
A tooltip for text is done as so:
JHtml::_('behavior.tooltip');
echo JHtml::tooltip('Tooltip Text', 'Tooltip Title', '', 'Text to be hovered over');
and a tooltip for an image, can be done like so:
JHtml::_('behavior.tooltip');
JHtml::tooltip('Tooltip Text', 'Tooltip title', 'tooltip.png', '', '', false);
For more information, please read the Joomla Docs on Tooltips: