//Php Function to read the images in a dir function getJsArray($dir) { $out = ""; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) if(in_array( substr(strrchr($file, '.'), 1) , array('gif','png','jpg') )) $out.= ($out?",":"")."'".$dir.$file."'"; closedir($dh); } else { die ("no dir"); } return $out; } ?> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> var gallery_current_pos = 0; // gallery counter position var gallery_idname = "container"; // id of the gallery container var gallery_timer = 5000; // 5 seconds var gallery_ar = Array(<?=getJsArray("./minislides/")?>); function goGallery() { if (gallery_current_pos>gallery_ar.length - 1) gallery_current_pos =0; $('#'+gallery_idname).fadeTo("fast", 0 , function () { $('#'+gallery_idname).css("background-image","url(" + gallery_ar[gallery_current_pos] + ")"); $('#'+gallery_idname).fadeTo("slow", 1); gallery_current_pos++; }); if (gallery_ar.length>1) setTimeout( function () { goGallery(); }, gallery_timer); } </script> <style> #container {background-repeat:no-repeat;width:300px;height:200px;} </style> <body onload="goGallery();"> <div id='container'> </div>
mam obrazki wielkosci 800x600, potrzebuje je wyswietlic w wielkosci 300x200 ale nie "obcinane" jak to teraz robi skrypt ale przeskalowane. jak to przerobic?