My code is using the heredocs operator to avoid all the echos. If you look it up in the manual you can see how it works. My code should work just fine except if a I have any typos of my own. You have to be php mode for ALL of it. If it doesn't work, post it again as is and let's see it. And be sure that the heredocs; line is in column 1 !!!
I do see where the image tags are showing but since you didn't provide any size values it may not be showing.
Do an echo of your img tag src value so you can see what the actual image file name looks like.