Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

How to Create Custom URLs for Images in 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, it is possible to customize your URL image links with the help of a filter.

In this documentation, we’ll walk through how to apply a filter to create custom URLs for images in your deeplinked 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 create custom whitelabel URLs, we’ll need to create and upload a basic WordPress plugin.

To create custom whitelabel URLs for images in deeplinked galleries, just add the following code to a new file at wp-content/plugins/envira-gallery-whitelabel-url-for-deeplinked-galleries.php.

This following code is set to change the Lightbox image URL in a deeplinked gallery to https://www.enviragallery.com/deeplinkme. On line 8 below, you will need to add your own custom URL.

add_filter( 'envira_whitelabel', 'test_envira_whitelabel', 10, 1);
function test_envira_whitelabel() {
return true;
}
add_filter( 'envira_whitelabel_envira_deeplinking_slug', 'test_envira_whitelabel_envira_deeplinking_slug', 10, 1);
function test_envira_whitelabel_envira_deeplinking_slug( $deeplinking_slug ) {
return 'deeplinkme';
}

If you’re unsure how to create a plugin file, follow these steps below:

  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 shown below that matches the page builder you’re using into the file, then save the file as envira-gallery-whitelabel-url-for-deeplinked-galleries.php
  3. Once you’ve 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. Upload the .zip file you just created in the previous step.

You can also choose to add this code to your theme’s function.php instead of creating a new plugin.

Next, you’ll need to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the plugin. That’s it!

[i]
[i]