Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

How to customize URLs for deeplinked galleries

With the Deeplinking Addon, you can directly link to a Lightbox view of any image in your gallery. The Envira Gallery plugin automatically generates a URL for your images when you enable deeplinking on your Lightbox galleries. But, is it possible to customize your URL image links?

In this documentation, we’ll walk through how to use a filter to create custom URLs for images in your deeplinked galleries.

Heads up!

This article contains PHP, CSS, and/or JavaScript to customize our plugin. We offer this code as a courtesy but don’t provide support for additional code customizations or 3rd party development.

First, you’ll need to add the following code snippet to your site to create the custom URLs for your deeplinked galleries.

If you need help adding custom code to your site, please check out our guide on adding custom PHP or JavaScript to your site.

/* Customize your URL image links with deeplinking
 * 
 * @link https://enviragallery.com/docs/how-to-create-custom-urls-for-images-in-deeplinked-galleries/
 */

add_filter( \'envira_whitelabel_envira_deeplinking_slug\', \'custom_envira_deeplinking_slug\' );
add_filter( \'envira_whitelabel\', \'__return_true\' );

function custom_envira_deeplinking_slug( $slug_name ) {
// Use your own slug replacing my_custom_slug
$custom_slug = \'my_custom_slug\';

return $custom_slug;
}

Customizing the snippet

After adding the snippet you’ll just need to be sure you replace my_custom_slug with whatever you want to appear in the URL instead.

 

Now you’re all set to add custom URLs to your Deeplinked galleries!