JavaScript to dynamically detect dimensions for responsive images in responsive websites