Linked and knotted synthetic magnetic fields