A trapped NPC can cast magic mouth on a rock, and then give it to a bird and then use speak with animals to ask the bird to carry it somewhere far away. (The NPC could even just cast magic mouth on the bird.) The magic mouth would wait until it met a group of adventurers and then speak a 25-word message. This does not give a visual message but I think it meets the rest of your criteria. Note that the NPC would need to have an unusual combination of spellcasting abilities to access both of these spells. A seventh-level bard could do it.
A trapped NPC with a great deal of free time can cast scrying a whole lot, scrying on birds and cats and rats. This spell grants a ten-foot radius of vision around the creature being watched, so in principle you could use this to become aware of other creatures and start scrying on them, and eventually you might find some adventurers. An NPC could attempt to cast message through the scrying spell to contact the adventurers.
A trapped NPC can cast divination to learn about adventurers who might be able to free them, and can then cast dream or sending to send them a message.
A trapped NPC can cast limited wish to do anything the DM feels is reasonable.
Or -- and this is the option I actually endorse -- you could make something up. NPCs are not required to follow the same rules as player characters. As the DM, you are allowed and encouraged to invent new abilities for them. You could narrate that someone has developed a custom spell during their time in prison. You could narrate that they've taken a custom feat which grants an unusual ability. You could narrate that they have an unusual bloodline, or a that they've crafted a custom magic item, or that they've invented a three-hour ritual that does the thing they want.
I've done this "make something up" thing many times and nobody has complained. In this case, I'd probably narrate that the trapped wizard has a rune on his forehead preventing him from teleporting, but that he's invented a spell that teleports a rock to a random location up to 500 miles away. So he's cast magic mouth on a whole bunch of rocks and teleported them across the continent, and they only trigger if they see a group of adventurers, and the player characters run into like five of them as they travel through the area.
(I might also narrate that the trapped wizard has a variant higher-level magic mouth spell that produces a visual component -- or I might decide that having a visual component to the message wasn't valuable enough to generate homebrew content for.)