0

I have an image to display thanks to a lighbox.

If I get the image online with a link http there is no problem but if I want to recover an image of the database I encounter a problem. I would like to display the image in the tag as below.

IF you have tracks I thank you in advance. Beautiful day

<a href="https://unsplash.it/1200/768.jpg?image=256" data-toggle="lightbox" data-gallery="gallery" class="col-md-4">
  <img src="https://unsplash.it/600.jpg?image=256" class="img-fluid rounded">
</a>

TO

<div class="row" *ngFor="let drawing of drawings;">
<a href="????" data-toggle="lightbox" data-gallery="gallery" class="col-md-4">
  <img style="max-width:400px;" *ngIf="drawing.image" [src]="drawing.image">
</a>
</div>
Valentin
  • 405
  • 2
  • 6
  • 17
  • this should answer your question https://stackoverflow.com/questions/45530752/getting-image-from-api-in-angular-4-5 – Guillaume Jun 21 '19 at 14:32

1 Answers1

1

Since you use angular, take advantage of it :

<div class="image-container" (click)="navigate()">
  <img src="...">
</div>
navigate() {
  const a = document.createElement('a');
  a.href = '...';
  a.setAttribute('data-toggle', 'lightbox');
  a.setAttribute('data-gallery', 'gallery');
  a.click();
  a.remove();
}

This will work as if you were actually clicking on a link, but you don't actually use alink in your template. Other than that, I don't see an issue with appending an image to a link :

<a href="google.com" target="_blank">
  <img src="https://via.placeholder.com/500x100?text=ImagePlaceholder">
</a>