Solved: Envira Gallery lightbox close button (X) missing

Envira Gallery is a very widely used gallery plugin for WordPress. All of a sudden one customer had the close button missing when clicked on the thumbnail and image opened in lightbox. No way to close, only refresh page or go back to get the image in lightbox away from screen.

To further add, WordPress was up to date (5.7.2), all plugins too and Envira Gallery version was 11.6.6.

Envira Gallery lightbox view not having a close button

Issue was weird because there is no option in the gallery configurator to turn the button on or off.

I tried to inspect the source and make the button forcefully always visible by adding CSS rule display: block !important; to #envirabox-close element. That actually worked to display the button, but it didn’t do anything.

When I opened the Inspector console in Chrome, some javascript errors were logged, one most significantly hinting one was: Uncaught TypeError: s.get(…).style.removeAttribute is not a function

How did I solve Envira Gallery lightbox image close button missing?

The solution was available in the internet wordpress.org forum, but weird enough, had been written almost 2 years ago with a request to have the fix included in the plugin-s following releases. Well seems it didn’t come, at least not with updating via WordPress admin.

The solution needs access to Envira Gallery files to edit one javascript file.

File to be updated: wp-content/plugins/envira-gallery-lite/assets/js/min/envira-min.js

Code:

1) s.get(0).style.removeAttribute(“filter”)
replace with: s.get(0).style.removeProperty(“filter”)

2) o.get(0).style.removeAttribute(“filter”)
replace with: o.get(0).style.removeProperty(“filter”)

PS! check the apostrophes – I had an issue when I copied them over from that WordPress forum, wrong apostrophes came to the .js file that broke it totally. Needed to re-type them with my keyboard (shift+2).

After applying the above code change the Envira Gallery close button appeared and worked as expected.

Hoping this solves someone some time and gray hair as I spent quite some time trying to figure out this issue with Envira Gallery lightbox close button missing.

Post Author: Tom Pai