I have tried replicating your code on my local system and found that images were coming twice because of :
".img-wrapper a", instead you have to use it as ".img-wrapper > a:first-child" after prepending anchor.
Fiddle here : http://jsfiddle.net/BvGXs/
Image are not loading due to path, although correctly prepended.