php - loading large images page load time -
i've tried couple of ways , have found issues both.
loading image ajax post, , updating img id source it. php function loads images in "li" list class set display:none , jquery hide/show image.my problem these images 1440px x 960px minimum. if load ajax post takes while show total image, , if load php loop takes veryyyy long time page load.
here illustration of php loop function:
public function loadstreamimages() { $imgs = '<li id="0"><img src="img/om.jpg" class="bgimg" /></li>'; if($db->num_rows($consulta)>0) { while($row = $db->fetch_array($consulta)) { $imgs .= '<li id="' . $row['id'] . '" class="hidden"><img src="img/' . $row['imagefile'] . '" class="bgimg" /></li>'; } } echo $imgs; }
anything can spead up?
i'd guess best solution between methods. send image info thru php load em javascript after page load....
<?php public function loadstreamimages(){ if($db->num_rows($consulta)>0) { $i =0; $imgs = array(); while($row = $db->fetch_array($consulta)) { $imgs[$i]['id'] = $row['id']; $imgs[$i]['imagefile'] = $row['imagefile']; $i++; } } echo "<script>myimages = ".json_encode($imgs).";</script>"; } ?>
and run foreach javascript after page load on myimages inserting <li>s , <img>s tags.
php jquery image loading
No comments:
Post a Comment