I personally try to avoid if/else/if/else because it tends to be hard to read. Its not awful right now, but I believe could be better. If we had method that return the type of media, we could use a switch statement and improve the legibility imo.

```javascript
// Discourse.Utilities.getMediaType returns a string representing the type of file.

return switch (Discourse.Utilities.getMediaType(upload.original_filename)) {
  case 'image':
    '<img src="' + upload.url + '" width="' + upload.width + '" height="' + upload.height + '">';
    break;
  case 'video':
  case 'audio':
    Discourse.getURL(upload.url);
    break;
  case 'link':
    '<a class="attachment" href="' + upload.url + '">' + upload.original_filename + '</a> (' + I18n.toHumanSize(upload.filesize) + ')';
    break;
}
```