Wordpress Images

How can I add an if statement to the following code to only show images if the thumbnail exists?

  {
    source: autocomplete.sources.hits(people, {hitsPerPage: 5}),
    displayKey: 'people',
    name: 'people',
    templates: {
      header: '<div class="aa-suggestions-category">People</div>',
      suggestion: function(suggestion) {
        return '<span>' +
        '<a href="' + suggestion.permalink + '">' +
        suggestion._highlightResult.post_title.value + '</a></span>' +
        '<span>';
      }
    },
  }