The linking issue is a valid concern of course. Maybe try the direct object model with $randomImage->getFullImageURL() instead of getURL($randomImage). (Funny side info: I had to look up if getURL() is one of ours actually, I think I never used it myself…:-)).