Add custom header before load image from server
amakhaev opened this issue · 2 comments
amakhaev commented
Hello. I want to add authorization
header before send request to server. Could you please clarify it is possible?
Angular version: 6.0;
ngx-lazy-load-images: 1.3.1
jesusbotella commented
Hello @amakhaev! Sorry for my late reply.
No, you can't set any authorization headers to the image request with this plugin. The only way I know to do it is fetching the image and setting it to the <img>
tag via blob content, like this:
fetch('your image URL', { headers: { "Authorization": "your authentication header" } })
.then(response => response.blob())
.then(blob => {
let url = URL.createObjectURL(blob);
document.getElementById('image').src = url;
})
And there's no way of doing that with this module. I am sorry ;)
amakhaev commented
Got it, thanks