I miss him – how change my thoughts?

I was having an affair with a man. It was an intense time and we did a lot together in our free time.  He stopped the affair and is now in a relationship with another woman. We wanted to keep the friendship, but he broke off our contact 4 weeks ago (ghosting).

Now I had an accident and a lot of time to think about the situation. He is constantly posting pictures of himself and his new wife. In my thoughts I am now constantly with him again. How do I get him out of my thoughts? I miss our time together.