Editorial content and matching online ads

Since I don’t care much about the real problems in the world, I was reading an article with a somewhat convoluted headline on the Daily Mail website:

Prince George may need to work on his geography! Toddler goes hunting for Prince William in the kitchen cupboards when told his father was in ‘China’

One passage in the article reads:

Scrolling down a little bit, I find this advertisement (which includes a link to a shopping site):

The ad uses (as far a I can tell) exactly the same picture of the pregnant Duchess of Cambridge in her dress as the article.

I’m wondering: Is this an example of online advertising algorithms working extremely well or does the Daily Mail actually produce it’s content with the surrounding advertisements in mind?

The Daily Wail almost certainly wrote the content so that they could sell space to Erdem.

I understand that the Daily Mail isn’t exactly the gold standard for respectability/quality in journalism, but it does have a brand recognition. I don’t recall seeing this kind of unabashed blending of editorial content and advertising, at least not on the website of a major newspaper.