This is jsfiddle, which is exceptional for the first example you linked. I juist changed the retrieval of data from JavaScript code instead of a json file, since jsfiddle does not support external json files, which is good.
First decision
Now replace the permanent image with many different images
Instead of this code:
.attr("xlink:href", "https://github.com/favicon.ico")
we will insert this code:
.attr("xlink:href", function(d) { var rnd = Math.floor(Math.random() * 64 + 1); var imagePath = "http://www.bigbiz.com/bigbiz/icons/ultimate/Comic/Comic" + rnd.toString() + ".gif"; console.Log(imagePath); return imagePath; })
and we get this :

Second solution
As you suggested in your code from the question, you can use the built-in SVG characters.
Instead, the entire segment for inserting images:
node.append("image") .attr("xlink:href", "https://github.com/favicon.ico") .attr("x", -8) .attr("y", -8) .attr("width", 16) .attr("height", 16);
we could use this code:
node.append("path") .attr("d", d3.svg.symbol() .size(function(d) { return 100; }) .type(function(d) { return d3.svg.symbolTypes[~~(Math.random() * d3.svg.symbolTypes.length)]; })) .style("fill", "steelblue") .style("stroke", "white") .style("stroke-width", "1.5px") .call(force.drag);
and we get this :

Hope this helps.
source share