Fix null error in lightbox plugin when element is deleted.

Partially fixes #5792 (For only the lightbox plugin)