title: How to add image to Mxgraph mxGeometry
body: <p>I am currently working on a project with MxGraph, and the components that I would like to render have been created by using the mxGeometry method. I have seen many answers on stackoverflow that suggest to add an image attribute to insertVertex or addVertex methods. But I have not used such methods.
  Here is a snippet from my code:</p>
  <pre><code>  class HyComp extends Component {
    constructor() {
      var w = 50;
      var h = 50;
  
      super(new mxGeometry(0, 0, w, h));
      this.style += &quot;strokeColor=black;fillColor=white;&quot;;
    }
  
    createChildren(name) {
      let w = this.geometry.width;
      let h = this.geometry.height;
  
      this.createLabel(name);
  
      var c_in = new mxCell(&quot;&quot;, new mxGeometry(-10, 5, 10, 10));
      c_in.vertex = true;
      c_in.connectable = true;
      c_in.connectionType = &quot;hydro&quot;;
      c_in.style =
        &quot;editable=0;movable=0;strokeColor=blue;fillColor=white;portConstraint=west;perimeter=none;&quot;;
      this.insert(c_in);
  
      var c_out = new mxCell(&quot;&quot;, new mxGeometry(-10, h - 10 - 5, 10, 10));
      c_out.vertex = true;
      c_out.connectable = true;
      c_out.connectionType = &quot;hydro&quot;;
      c_out.style =
        &quot;editable=0;movable=0;strokeColor=blue;fillColor=white;portConstraint=west;perimeter=none;&quot;;
      this.insert(c_out);
  
      this.setDimensions(10, 0, w + c_in.geometry.width, h);
    }
  }
  </code></pre>
  <p>And this is how the class <code>Component</code> looks like :</p>
  <pre><code>class Component extends mxCell {
    constructor(geometry) {
      super(&quot;&quot;, geometry);
  
      this.vertex = true;
      this.connectable = false;
      this.isComponent = true;
      this.componentName = this.constructor.name;
      this.userName = &quot;&quot;;
      this.setNewId();
      this.style = &quot;editable=0;movable=1;&quot;;
  
      this.setDimensions(0, 0, 0, 0);
    }
  </code></pre>
  <p>I have been trying to insert an image as the background for these cells for several days now, but not successful.</p>