Envira Gallery: Stuck Adding items to gallery

Hey all, just came across this issue using Pro v6.3.8 and Envira v1.9.5. Writing in, in case it’s helpful for others as a hot fix.

When editing a gallery, I sometimes came across an issue where I would delete some images, and then try re-add some back in, and nothing would happen other than an infinite “Adding items to gallery” spinning notification.

I did a bit of digging and found that there’s an error in the plugin itself: the bulk delete feature doesn’t work properly. Delting single images is fine, but doing it by bulk is broken.

It’s not advisable to do this, but you can do a hot fix (as we have done) to get it working as it should:

  1. Open up /wp-content/plugins/envira-gallery/src/Functions/ajax.php in a text editor
  2. Navigate to line 512. You’ll see something like:
	foreach ( (array) $attach_ids as $attach_id ) {
		$has_gallery = get_post_meta( $attach_id, '_eg_has_gallery', true );
  1. Change it instead to be:
	foreach ( (array) $attach_ids as $attach_id ) {
		$attach_id = absint($attach_id);
		$has_gallery = get_post_meta( $attach_id, '_eg_has_gallery', true );

Please note that changing plugin files directly like this is not usually a good idea. And that any updates to the plugin down the track will override any changes you make.

However @charlie - my hope is that you’d see this, and either pass this issue on to Envira or do a review of the next Envira release as soon as you can (because they may have already fixed it) :wink:

1 Like

Hey @conorseed,

Thank you for sharing this information. I will be forwarding this thread to @charlie

Cheers.

Hey thanks for the notes on this one. I do see something related to the envira change log on this. There should be an update to envira going out today. Let me know if you still have this issue and I can send this to Envira from there. Have a great day!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.