Thanks for looking into it.
The theme I’m using had originally a different lightbox plugin, which I disabled to install SLB.
This issue could be the result of an interference from another plugin, from the theme or from the code I’ve changed, but I’m afraid I wouldn’t know which one is it.
In any case, the solution you proposed is brilliant and everything is working fine now ??