bqworks / slider-pro

A modular, responsive and touch-enabled jQuery slider plugin that enables you to create elegant and professionally looking sliders.
MIT License
877 stars 390 forks source link

Get Image Data #326

Open lucasjmiles opened 2 years ago

lucasjmiles commented 2 years ago

Not sure but how would I retrieve the current image data of the slide? Ie: the image url...

Im confused, this should be a base function or atleast some documentation concerning this.

   ```

var slider = $('#slider-car-details').data( 'sliderPro' );

    $( '#slider-car-details' ).on( 'gotoSlide', function( event ) {
        console.log( event.index );
        var $target = event.target;    
        var data = slider.getSlideAt(event.index)        
        console.log(data);
        var image = data.mainImage;
        console.log(image);

    })
davidghi commented 2 years ago

If you want to use getSlideAt, this will return the image source: console.log(data.$mainImage[0].src), as you can see if you inspect the object returned by the method, but this method is mainly for retrieving other type of data, like the settings. To get attribute values, you could use this instead: console.log($mySlider.find('.sp-selected .sp-image').attr('src'));

Best, David