Custom jQuery slider image calculation -
i using code jquery image slider found work custom post type in wordpress(pods). slider working perfectly, need limit number of times user can scroll next image based on how many images there are.
<script type="text/javascript"> $(function() { $("img.enlarge").live('click', function (e) { e.preventdefault(); var src = this.src; $("#fullimage").attr("src", src); }); }); $(document).ready(function() { $('img').filter(function(index){return $(this).attr('src')==='';}).removeclass('enlarge'); $('img').filter(function(index){return $(this).attr('src')==='';}).hide(); var $item = $('img.enlarge'), //cache dom selector visible = 1, //set number of items visible index = 0, //starting index endindex = ( $item.length / visible ) ; //end index (note:: requires visible factor of $item.length... can improve rounding...) $('div#arrowr').click(function(){ if(index < endindex ){ index++; $item.animate({'left':'-=275px'}); } }); $('div#arrowl').click(function(){ if(index > 0){ index--; $item.animate({'left':'+=275px'}); } }); }); </script> <div class="detail-slider-thumbs" id="detail-images"> <img class="enlarge" src="{@main_image}"/> <img class="enlarge" src="{@image_2}"/> <img class="enlarge" src="{@image_3}"/> <img class="enlarge" src="{@image_4}"/> <img class="enlarge" src="{@image_5}"/> </div>
so, if user uploads 4 images, need code dynamically respond number , not scroll blank image spot does.
Comments
Post a Comment