In The Hobbit: the Desolation of Smaug, when the dwarves get captured in the forest by the elves, Legolas takes a photo from one of the dwarves, and the dwarf states that’s Gimli. I'm aware who that is from Lord of the Rings, but how do they connect to each other?
TL;DR: Gimli (depicted in the locket, and from The Lord Of The Rings) is the son of Glóin (in The Hobbit).
Glóin is the dwarf that shows Legolas the locket.
Glóin: Give it back, that's private!
Legolas: Who is this? Your brother?
Glóin: That is my wife.
Legolas: And what is this horrid creature, goblin mutant?
Glóin: That's me wee lad, Gimli.
In The Fellowship of the Ring, Gimli is mentioned specifically as "the son of Glóin".
“For the rest, they shall represent the other Free Peoples of the World: Elves, Dwarves, and Men, Legolas shall be for the Elves; and Gimli son of Glóin for the Dwarves. They are willing to go at least to the passes of the Mountains, and maybe beyond. For Men you shall have Aragorn son of Arathorn, for the Ring of Isildur concerns him closely”
Gimli, Son of Gloin
He's also Balin's cousin(?)