Supersized Slideshow loading images from list instead of javascript

917 Views Asked by At

i'm trying to modify the supersized slideshow plugin to get images from a list ( inside the html source ) and not from the javascript. The aim of this trick is to let google indicize the images.

this is the original code

<script type="text/javascript">
        jQuery(function($){
            $.supersized({
                slide_interval          :   3000,
                transition              :   1,
                transition_speed        :   700                     
                slide_links             :   'blank'
                slides                  :   [

{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''},
{image : 'image.jpg', title : 'title', thumb : 'image.jpg', url : ''}

                                            ]
            });
        });

</script>

and i would like to use a code like this

<ul id="supersized">
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
<li><img alt="text" title="text" src="image.jpg" /></li>
</ul>


<script type="text/javascript">
        jQuery(function($){
            $.supersized({
                    <code>
</script>

can anybody help me ? :)

1

There are 1 best solutions below

0
Devima On

I found a solution to your problem
This is the FIDDLE
this is the jQuery code

<script type="text/javascript">
    jQuery(function($){
        var obj={
            slide_interval          :   3000,       
            transition              :   3,          
            transition_speed        :   700,        
            slide_links             :   'blank',    
            slides                  :   []          
            }

        var arrImg=[]   
        for(i=0;i<$('#supers li').length;i++){
            var srcImg=$('#supers li:eq('+i+')').find('img').attr('src')
            arrImg.push(srcImg)
            }
        for(x=0;x<arrImg.length;x++){
            obj.slides[x]={image:arrImg[x]}

            }
        $.supersized({
            slide_interval          :   obj.slide_interval,     
            transition              :   obj.transition,             
            transition_speed        :   obj.transition_speed,       
            slide_links             :   obj.slide_links,    
            slides                  :   obj.slides

        });

    });

</script>

First of all i insert all src attributes of image in array
with this array i create properties in obj.slides array (first object of script)
and then i use this obj object for set parameters for supersized plugin.
for this result i used the scripts and css that i found in the plugin's download package, check "external resources" tab of fiddle page.
A shortest way to get the same result coul be this Fiddle
instead of creating an array in this case i add images paths directly in obj