title: If the src I am using does not exist, use this src
body: <p>I am experiencing in issue where in cases where I do not have an image that matches the data code no image is returned. I would like it so that my function checks if the file is there before appending it to the html - if it is not an actual image that I have available; I would like it to use one specific image.</p>
  
  <p>Here is the code I have so far.</p>
  
  <pre><code>            handleError: function(image) {
        image.onerror = "";
        image.src = "dog/dma/_resized/beagle.png";
        return true;
    },
  
      tplItem: function(id, name, regional, national) {
  
  
        var image_name = name.replace(',', '').replace(/\s/g, '').toLowerCase();
        var image_html = '&lt;div class="st-rounded-12 img overflow-hidden"&gt;' +
          '&lt;img src="' + this.imageDir + '/' + id + '/_resized/' + image_name + '.jpeg" alt="" onerror="handleError(this);"&gt;' +
          '&lt;/div&gt;';
  
        return '&lt;div class="columns shrink"&gt;' +
          '&lt;div class="breeds-chart-wrapper flex-container align-bottom align-center"&gt;' +
            '&lt;div class="breeds-chart"&gt;' +
              image_html +
              '&lt;div class="flex-container align-bottom align-center line-chart-wrapper"&gt;' +
                '&lt;div class="line-chart text_22_32 font_avenir_roman font-weight-bold bg-red-light color-red-light" style="height: calc(25vh/100 * ' + regional + ')"&gt;' +
                  '&lt;span class="text"&gt;' + regional + '%&lt;/span&gt;' +
                '&lt;/div&gt;' +
                '&lt;div class="line-chart text_22_32 font_avenir_roman font-weight-bold bg-green color-green" style="height: calc(25vh/100 * ' + national + ')"&gt;' +
                  '&lt;span class="text"&gt;' + national + '%&lt;/span&gt;' +
                '&lt;/div&gt;' +
              '&lt;/div&gt;' +
            '&lt;/div&gt;' +
          '&lt;/div&gt;' +
          '&lt;div class="text-center chart-text text_22_32 color-aluminium font_avenir_roman font-weight-bold"&gt;' + name + '&lt;/div&gt;' +
        '&lt;/div&gt;';
  </code></pre>