Yoenis Cespedes of the Mets celebrates in the dugout against...

Yoenis Cespedes of the Mets celebrates in the dugout against the Cardinals at Citi Field on July 19, 2017. Credit: Jim McIsaac

Perhaps this is how it must be from here on out, the most prominent player on the Mets picking and choosing precisely when to demand more from his weary legs.

Sometimes, Yoenis Cespedes finds another gear, flashing the speed he still possesses despite constant worry about the leg injuries that have put a dent in his career. Sometimes, he barely reaches a steady jog, inviting questions about whether his body will hold up.

Either way, this is the bargain that the Mets find themselves locked into as they enter the trade-whatever-you-can-for-prospects phase of their campaign. Both versions of Cespedes showed up on a steamy Wednesday night at Citi Field, where the Mets battered the Cardinals, 7-3, to end a three-game losing streak.

“He knows what he can catch and what he can’t,” manager Terry Collins said. “I know he’s trying to make sure nothing happens so he stays on the field.”

The Mets improved to 42-50, though they began the day 11 1/2 games out of the wild card. And deGrom cruised, lowering his ERA to 1.51 in his last seven starts. He was charged with only one run in 6 2/3 innings.

But Cespedes loomed large on a night in which he donned a bright new hair color. His explanation through a translator: “because I wanted to.” It was a shade of blue once made famous by Marge Simpson. And it seemed to work. Cespedes knocked in a pair of runs.

The run-scoring hits came one day after manager Collins acknowledged “a little concern” about the slugger’s production. Entering play on Wednesday, Cespedes hadn’t homered since June 23, a span of 62 at-bats. Until Wednesday night, he had driven in only one run in his last 15 games. He began the evening hitting .272 with nine homers and 20 RBIs, having been sidelined for six weeks with a hamstring and quad injury.

But Cespedes helped the Mets pounce on Cardinals starter Mike Leake, providing ample cushion for righthander Jacob deGrom (11-3), who has won his last seven starts.

“Obviously, things haven’t been going great for me,” Cespedes said. “But I’m not going to get discouraged. I’m not going to work any less hard. I’m going to continue working hard and work my way through this.”

In the first inning, Cespedes ripped an RBI single to left, the fist of three-straight run-scoring hits with two outs that the Mets used to build a 3-0 lead. In the second, Cespedes struck again, lacing a run-scoring double to leftfield.

But Cespedes did not run hard out of the batter’s box. Within moments, Collins and team trainer Ray Ramirez were on the field checking on the slugger, who is in the first season of a four-year, $110 million extension.

Cespedes complained that the muggy air made it difficult to breathe. Though he quickly waved off assistance and stayed in the game, only a half inning passed until he looked once more like a player finding a way to deal with unsteady legs.

In the third inning, Magneuris Sierra lofted a fly ball to shallow left. It appeared to be within range of an average big- league outfielder in a full sprint. But with a 7-0 lead, Cespedes jogged after it, letting it hit the grass in front of him for a hit. Yet, later in the frame, he looked like a flash streaking across leftfield as he ran down Tommy Pham’s liner.

“If the chance comes up again where I have to dive, I’ll dive,” Cespedes said, brushing off the notion of choosing when to run hard or leave his feet. “And if I get hurt I’ll get hurt, that’s just what happens.”

But Collins nevertheless wondered if Cespedes might still be dealing with the quad issue that hampered his rehab. He also questioned whether Cespedes’ sore hip had returned to full strength, an injury he suffered after diving after a ball on Saturday.

Whatever the severity, Collins deferred to Cespedes’ judgment to do what it takes to ensure “his legs don’t go out on him,”

Said Collins: “He knows how he feels better than anybody.”