<ng-template #img>
  @if (displayImage()) {
    <img #avatarEl [ngClass]="classes" [src]="previewImage() || avatarUrl || defaultAvatarUrl" alt="" />
  } @else if (displayActorInitial()) {
    <div #avatarEl [ngClass]="classes">
      <span>{{ getActorInitial() }}</span>
    </div>
  } @else if (displayPlaceholder()) {
    <div #avatarEl [ngClass]="classes"></div>
  }
</ng-template>

@if (actor() && href()) {
  <a [href]="href()" target="_blank" rel="noopener noreferrer" [title]="getTitle()">
    <ng-template *ngTemplateOutlet="img"></ng-template>
  </a>
} @else if (actor() && internalHref()) {
  <a [routerLink]="internalHref()" [title]="getTitle()">
    <ng-template *ngTemplateOutlet="img"></ng-template>
  </a>
} @else {
  <ng-template *ngTemplateOutlet="img"></ng-template>
}
