I concur with Jason's assessment of the initial solution I proposed, it can definitely be improved. My solution represents an older school javascript mentality (read, pre the emergence of ajax and json). There are always better ways to solve a problem, which one of the reasons why stackoverflow is so cool. Collectively we are better at the craft of programming than anyone of us on our own.
Based on Jason's ideas I'd revise my initial code, and revise some of what Jason suggested. Implement a C# class with two properties, the img resource "id" and a property that contains the WebResourceUrl. Then, where I differ some from Jason is that rather than using a Dictionary I'd propose using a List, which you can then in turn serialize to JSON (using DataContractJsonSerializer), and emit the JSON as the dynamic script, rather than manually generating the javascript using a string buider.
Why a List? I think you may find that dictionaries when serialized to json, at least using the DataContractJsonSerializer (fyi available with the 3.5 framework only, with the 2.0 or 3.0 framework you'd need to bolt on aspnet ajax and use is json serializer), are a little more cumbersome to work with than how a list would serialize. Although that is subjective.
There are implications too with your client side code. Now on the client side you'll have an array of the json serialized MyImageResourceClass instances. You'd need to iterate through this array creating your "img" tags as you go.
Hopefully these ideas and suggestions can help get you going! And no doubt there are other solutions. I'm interested to see what comes of this.