Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

Changing the Transition Speed for Lightbox Images

Would you like to speed up or slow down the transition speed for lightbox images? We will help you create a custom plugin that will help you complete this in a step by step process and we’re with you every step of the way! This custom function can be used for Envira galleries.

This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to change the lightbox transition speed, we’ll need to create and upload a basic WordPress plugin.
  1. Creating the Plugin
  2. Activate the Plugin
  3. FAQs

Create the Plugin

To change the transition speed for lightbox galleries, just add the following code to a new file at wp-content/plugins/envira-lightbox-transition-speed.php.

<?php
/*
* Plugin Name: Envira Gallery - Control Lightbox Transition Speed
* Plugin URI: https://enviragallery.com
* Version: 1.0.0
* Author: Envira Gallery Team
* Author URI: https://enviragallery.com
* Description: Controls the speed of navigating, opening and closing Envira Galleries
*/
add_filter( 'envira_gallery_get_config', 'my_envira_gallery_get_config', 10, 2 );
function my_envira_gallery_get_config( $data_config, $key ) {
	if ( $key === 'transition_duration' ) {
		$data_config['transition_duration']   = 5000;
	}
	if ( $key === 'animation_duration' ) {
		$data_config['animation_duration']   = 5000;
	}
	return $data_config;
}

In the above code you can see return 5000;. This means when you open, close or navigate through your lightbox images, it will do this in 5 seconds (5000 milliseconds).

Not sure how to do that? Just follow these steps:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code above into the file and save the file as envira-lightbox-transition-speed.php. Remember to set the value of the transition you desire. (5000 = 5 seconds).
  3. Once you have saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Activate the Plugin

Your last step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Envira Gallery – Control Lightbox Transition Speed plugin.

you can easily control the transition speed from this plugin

And that’s it! You are now controlling the transition speed for all lightbox images. Want even more control over how your gallery displays? See our guide on how to limit your gallery to show only a certain number of images.

FAQs

Q: Can I change the speed per gallery?

A: Unfortunately no. Once the plugin is installed and activated it will be applied to every gallery that has the lightbox enabled.


Q: Can I change the speed for albums?

A: Unfortunately not at this time. This is only for galleries.