Opening photoswipe via javascript API
-
Hello, I have to open a gallery (which is anyway possible to open by clicking on it) as well on a button which is situated next to it.
For that purpose, I should be able to call a photoswipe opening function in frontend.min.js, to open the lightbox.
I did not find other way (except maybe sending click event to element in question, I did not go with this), than to modify your javascript code by exposing openPhotoSwipe function:
line 196:
window.openPhotoSwipe = function(element_index, group_index, element, fromURL, returnToUrl) {However, this change will break with next update of your plugin, so I tried to dequeue that script enqueued in your plugin, and then enqueue my version in functions.php, but I am losing plugin buttons functionality.
Therefore, currently the best option is probably to send click event.
Is there a better way to do this? Would you consider to expose simple API so it can be called from Javascript?
- The topic ‘Opening photoswipe via javascript API’ is closed to new replies.