php - optimized way to scale image -
i have following function runs thought 25 times , delays site's load time 10 seconds or more. code doing working out height when image's width scaled down or 310px. suggestions on how improve code or suggest option? maybe jquery might better this?
function img_height($image){ $inputwidth = 310; list($width,$height) = getimagesize($image); if($width !== $inputwidth){ $outputheight = ($inputwidth * $height)/ $width; }elseif($width == $inputwidth){ $outputheight = $height; } return 'style="height:'.$outputheight.'px;" '; }
@enigmo - have worked lot image loading , dynamically changing sizes. cannot make big difference in loading time using php. suggest use ajax , preload images or lazy loading. way site gets loaded first , images keep showing , when loaded.
Comments
Post a Comment