Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
<script>

jQuery(document).ready(function()
{
    jQuery('#view_gallery').click(function()
    {
        var project_id = jQuery(location).attr('href').split("=")[1];
        jQuery.ajax(
        {
            type: "GET",
            url: "../project_listings/project_gallery.php?project_id=" + project_id,
            dataType: "JSON",
            success:function(data)
            {

                    var pswpElement = document.querySelectorAll('.pswp')[0];

                    // build items array
                    var items = [
                        {
                            src: 'PhotoSwipe-master/website/test/1.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/2.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/3.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/4.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/5.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/6.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/7.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/8.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/9.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/10.jpg',
                            w: 1200,
                            h: 900
                        },
                        {
                            src: 'PhotoSwipe-master/website/test/11.jpg',
                            w: 1200,
                            h: 900
                        }
                    ];

                    // define options (if needed)
                    var options = {
                        // optionName: 'option value'
                        // for example:
                        index: 0 // start at first slide
                    };

                    // Initializes and opens PhotoSwipe
                    var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
                    gallery.init();
                }
            });
        });
});
</script>
Posted
Comments
Janardhanam Julapalli 24-Apr-15 5:48am    
In the above code I need to replace the src with dynamic values coming from database(php).How can I do this? Quick help required!Thanks in Advance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900