Prerender function to remove images outside of the viewport