Add alt text to Galleria lightbox - wordpress

I'm using the Galleria slideshow in WordPress 3.0 (inFocus 3.0 theme). Currently each slide in the slideshow has 2 captions - the title, and an alt text. The wp shortcode is: [image title="My title" alt="My alt text"]http://www.mywebsite.com/wp-content/uploads/myimage.jpg[/image]
Clicking the image launches a lightbox that displays the image title (bottom left) and a slide count(bottom right).
If possible I'd like to be able to display the title followed by the alt text eg. "My image title: My alt text". I know the div container I need to target is .galleria-lightbox-info, within which is .galleria-lightbox-title. I guess I need to add another div in there called .galleria-lightbox-alt? I can't seem to find any files (php, js, css etc) relating to galleria anywhere in my wordpress folders!

I know you posted this in 2012, but here is the answer to your question. I had to get this working for WCAG compliance. I am actually using ASP.NET so the <%=Name%> are place holders. Simple add this to the page where you are using the Galleria Tool. I have it scripted before the closing body tag. The big catch is the setTimeout, because you have to give the light-box time to load.
Galleria.ready(function () {
this.bind('image', function (e) {
// UNCOMMIT FOR TESTING // console.log(this); // the gallery scope
$('.galleria-image').find('img').attr('alt', '<%=Name%>');
});
this.bind('thumbnail', function (e) {
// add alt to thumbnails image
e.thumbTarget.alt = e.galleriaData.original.alt + " ThumbNail(s)";
});
$('.galleria-image').mouseup(function () {
setTimeout(function () {
$('div.galleria-lightbox-image').children().children().attr('alt', '<%=Name%>');
}, 5000);
});
$('.galleria-lightbox-prevholder').click(function () {
$('div.galleria-lightbox-image').children().children().attr('alt', '<%=Name%>');
});
$('.galleria-lightbox-nextholder').click(function () {
$('div.galleria-lightbox-image').children().children().attr('alt', '<%=Name%>');
});
});

Related

How do you add a custom button to the Elementor Text Editor widget toolbar?

I'm trying to add a custom button into the Elementor text widget toolbar next to other buttons like Bold, Italic, Underline etc. It seems that the ability to customize the instance using PHP may be disabled but that it is possible to do so using JavaScript instead.
I can get back the view by using the following code but I'm unable to get back the editor instance.
elementor.hooks.addAction( 'panel/open_editor/widget/text-editor', function( panel, model, view ) {}
I've tried the following suggestions but none seem to return anything after that.
// get active instances of the editor
let editor = tinymce.activeEditor;
var editor = elementor.editors.get(0).getEditModel().get('editor');
var activeEditor = view.getOption('editor');
The rest of the suggested code after getting the editor instance is as follows but I don't get this far.
// add a button to the editor buttons
editor.addButton('tooltip', {
text: 'tooltip',
icon: false,
onclick: (editor) => {
tooltipCallback(editor);
}
});
// the button now becomes
let button=editor.buttons['tooltip'];
// find the buttongroup in the toolbar found in the panel of the theme
let bg=editor.theme.panel.find('toolbar buttongroup')[0];
// without this, the buttons look weird after that
bg._lastRepaintRect=bg._layoutRect;
// append the button to the group
bg.append(button);

how to use page scroll to id plugin on page template in wordpress?

I have homepage which is created by using multiple small template pages in wordpress. I have set menus on it . now i want to go on particular section/ template using menu. like if i press contact menu button then it should go smoothly downwards of homepage where the contact template has been called. I am using "Page scroll to id" plugin of wordpress but its not working. I have also seen that this plugin work when the page is created by dashoard page. Please help me , how can i navigate to my template page/section using this plugin. If any other plugin is there , please tell me about it . i will try to use that too.
Thanks
To create smooth scroll on link click follow the below steps :
Step 1: Add section ids in menu href including #section1 from admin section Appearance >> Menu .
Step 2: Create section or div with id name section1.
<div id="section1"></div>
Step 3: Paste the below code under your custom js file.
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
});
I hope it will helps you.

Tweak TinyMCE Window after opening

I have this annoying thing that although is not a blocker-blocker, is very annoying. Let me explain.
I have this code inside of a MCE plugin:
var theWindow = editor.windowManager.open({
html: '<iframe id="iframeID" src="iframeURL" frameborder="0"></iframe>',
buttons: [
{
text: 'Cancel',
subtype: 'secondary'
},
{
text: 'Submit',
onclick: 'submit',
subtype: 'primary mySubmitButton'
}
],
});
$('#iframeID').on('load', function(){
selectedSnippets.on('change', function(e){
theWindow.statusbar.$el.find('.mySubmitButton .mce-txt').text(text);
});
});
(I avoided the plugin declaration and the code that will trigger the window opening for brevity)
Ok, so this works, the window is opened, it does have a title, a footer and two buttons on this footer.
My issue now is this: how do I update the text on the footer buttons? I mean I could simply do it with js. That works, but the problem is the buttons are positioned absolute and computed on first render:
So, my question is: how the hell do I re-render those buttons? The documentation of TinyMCE doesn't really help (or I may not know what/where to look for).
And as a subquestion: how to disable one button?
Thanks!
I managed to re-render the buttons in two steps in a probably not-so-clean way:
// you will need to run this for each **updated** button
theWindow.statusbar._items[0].$el.find('.mce-txt').text('my long value goes here');
theWindow.statusbar._items[0].updateLayoutRect();
// You will need to call this once
theWindow.statusbar.reflow()
I still have no idea how to disable/enable buttons though :)

wp_enqueue_scripts in TinyMCE Modal

I'm creating a simple WordPress plugin that requires wp_enqueue_media() to be called from a TinyMCE pop up in order to upload and/or select an image.
The issue im having is wp_enqueue_media() and wp_enqueue_script() don't appear to work with the TinyMCE pop up modal.
I am including wp-load.php in my modal window.
Is there a way to utilize native WordPress script loading within a TinyMCE modal?
Here is an example of what I am doing.
http://return-true.com/adding-tinymce-button-to-wordpress-via-plugin-part-2/
Like I already said in my comment, I think the best approach is to use an inline modal (no iframe).
It is very simple: using the 1st part of the article (http://return-true.com/adding-tinymce-button-to-wordpress-via-a-plugin/) as a basis, just replace the JavaScript with the following (copied from TinyMCE guidelines):
(function() {
tinymce.PluginManager.add('example', function(editor) {
// Add a button that opens a window
editor.addButton('example', {
text: 'Example',
icon: false,
onclick: function() {
// Open window
editor.windowManager.open({
title: 'Example plugin',
body: [
{type: 'textbox', name: 'title', label: 'Title'}
],
onsubmit: function(e) {
// Insert content when the window form is submitted
editor.insertContent('Title: ' + e.data.title);
}
});
}
});
});
})();
After that, you have a simple modal, with no iframe, thus using the native Wordpress script loading.
If the content must be in an iframe (which I doubt), one option is to create a 'blank' page in Wordpress with a page template of its own and use that page as the modal content. I actually tested that it works, but it is clearly more complicated (requires something like a blog post to explain).
The issue was that I was not including wp_head() and wp_footer() in the modal window html.
Adding these functions solved the enqueue issues.

ckeditor change button icon dynamically

I am trying to write a plugin for ckeditor, like in the link below
CKEditor Custom Plugins Button
the problem is, I want the button to change once I click it, and change back, so the users knows something happened. how can i change the path to the icon after the button is added? is there something like editor.ui.editButton?
Thanks!
$('.cke_button__BUTTONNAME_icon').css('background-position', '0 0').css('background-image', 'url(pathtoimage)').css('background-repeat','no-repeat');
Where BUTTONNAME is all in small letters and pathtoimage is relative to html file.
To chance image path to relative to the plugin.js by using this.path. Important thing this.path should be outside the scope of function as shown below:
var _p = this.path;
editor.addCommand('toggleAutocorrect',
{
exec : function()
{
$('.cke_button__toggleautocorrect_icon').css('background-position', '0 0').css('background-image', 'url("' + _p + '/images/autocorrectOff.png")').css('background-repeat','no-repeat');
}
}
});
editor.ui.addButton('ToggleAutocorrect',
{
label: 'Toggle Autocorrect',
command: 'toggleAutocorrect',
icon: this.path + 'images/toggleAutocorrect.png'
});
i have a dirty hack: (with jQuery)
$('.cke_button_COMMANDNAME.cke_icon').css('backgroundImage', 'url('+thisPath+'imageOff.gif)');
Where Commandname the name of the Button is and this path is a var wich i initiate in the plugin with
var thisPath = this.path;

Resources