Added error checks for image rendering, use in link_to commands