Only generate thumbnail if needed