The photograph is a wound to the heart: a toddler lying in shallow waters, clinging to her father; an innocent human life lost in an illegal passage across perilous waters.

It’s horrific that 23-month-old Valeria Ramírez and her dad, Óscar Alberto Martínez Ramírez, El Salvadoran migrants trying to cross from Mexico into the United States, drowned in the attempt.

It is a tragic illustration of the crisis we face on the southern border.

But for Democrats, it’s an excuse for cheap moralism.

Beto O’Rourke tweeted that he holds Trump “responsible for these deaths,” while The New York Times ran a front-page story all but making the same point.

What Beto didn’t tweet, what the Times didn’t print, what, in fact, no Democrat says is: What, exactly, should the government do about this?

The answer they appear to suggest is that our borders should be completely open. Yet few of them have the courage to say so — because they know most voters in this country disagree.

Oh, they’ll talk about “comprehensive immigration reform” and “amnesty for Dreamers,” but that has nothing to do with the tens of thousands arriving every day from Central America.

To slow down the surge, President Trump limited the number of people who could apply for amnesty each day. Óscar Ramírez got frustrated waiting, his wife told reporters, which is why he tried to cross the river. Because of our broken asylum laws, putting one foot on American soil meant he would be allowed to stay.

Democrats argue that trying to meter the traffic at the border is heartless, that Trump should just let everyone in.

That happens with plenty of migrants. Such families are processed at one of our overwhelmed holding facilities. But Alexandria Ocasio-Cortez calls these “concentration camps,” and Democrats have been fighting among themselves about giving money to Trump to improve their conditions.

So no holding facility (say the Democrats). The migrants are waved in, given a court date for their asylum plea and sent . . . where?

Perhaps they show up for their hearing. Ramírez’s mother told El Diario de Hoy that he came to the US in search of more money. Understandable, except we don’t grant asylum for economic reasons. When migrants are rejected in court and deported, Democrats argue that the government is heartless. If they skip the hearing and live here illegally for years, perhaps decades, Dems believe ICE shouldn’t be able to find or prosecute them.

In short, there are no restrictions that are reasonable to the Democratic presidential front-runners. And to whether the US can absorb millions of mostly economic migrants into our economy and welfare systems, the objections are waved away.

When Syrian boy Alan Kurdi drowned in 2015 while he and his family attempted to cross the Aegean Sea into the Greek isles, it was a similar shock to Europe.

At least Europe’s open-borders advocates were, well, open about their vision. “Wir schaffen das,” German Chancellor Angela Merkel famously declared. “We can do this” — that is, absorb more than a million new arrivals from Syria, Iraq, Afghanistan, Iran and elsewhere.

Racked by a particularly German brand of guilt, born of her country’s awful 20th-century history, Merkel flung open Europe’s gates with nary a concern for the feelings and capabilities of frontline nations like Greece, Italy and the fragile Balkan States. Chaos ensued as these countries opened and closed their borders and migrant flows shifted accordingly. Filthy, overcrowded camps sprang up as the frontline countries struggled to process human wave after wave.

Human smugglers — like the ones that boarded Alan Kurdi’s family into an unseaworthy plastic dinghy — prospered. I know, because I went undercover and embedded for several days with a group of Iranian and Afghan refugees hiding at a smuggler’s den in Istanbul.

Eventually, Merkel begrudgingly acceded to an upper limit on the number of refugees Germany would accept, and the European Union struck a deal with Turkish strongman Recep Tayyip Erdogan to keep the Syrians and others within his borders. They could still claim asylum in Europe, but they had to stay put in Turkey in the meanwhile.

Sound familiar? That’s also what Trump is trying to achieve with the “Remain-in-Mexico” plan, which among other things is supposed to cut the coyotes’ incentives and ensure that families don’t make perilous journeys, during which they’re at risk of heat, drowning and rape by traffickers.

These are the cruel realities of mass migration. The only way to reduce the likelihood of tragedies like the one that befell the Ramirez family is to discourage migrants from making the dangerous trek in the first place.

But don’t bet on the Democratic candidates soberly discussing these issues. Grandstanding and drawing false parallels are much easier than dealing with the world as it really is.

Sohrab Ahmari is The Post’s op-ed editor and author of “From Fire, by Water: My Journey to the Catholic Faith.”