javascriptphotoswipe

Is it possible to disable the share Button from outside?


I'm disabling the share button from inside of photoswipe-ui-default.js file right now. However I'm wondering whether there is a posibility to do it from outside of that code?


Solution

  • Well I would just disable it through the options listed in the documentation: https://photoswipe.com/documentation/options.html

    Image of documentation

    Otherwise you could do the following:

    <script>
    var divsToHide = document.getElementsByClassName("pswp__button pswp__button--share"); //divsToHide is an array
    for(var i = 0; i < divsToHide.length; i++){
        divsToHide[i].style.visibility = "hidden"; // or
        divsToHide[i].style.display = "none"; // depending on what you're doing
    }
    </script>

    Taken from: Hide all elements with class using plain Javascript