-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config to set image as blob #352
Comments
Yes, I want to add the ability to add custom load- and set-functions (see #304). But I guess you should be able to load a blob as it is: @Component({
selector: 'my-image',
template: `
<img
[defaultImage]="defaultImage"
[errorImage]="errorImage"
[lazyLoad]="image"
(onLoad)="onLoad($event)">
`
})
export class MyImageComponent {
errorImage = 'https://i.imgur.com/XkU4Ajf.png';
defaultImage = 'https://www.placecage.com/1000/1000';
image = this.defaultImage;
loaded = false
onLoad(success: boolean) {
if (!success || loaded) {
return
}
this.loaded = true
fetch('https://demo.cloudimg.io/width/616/n/https://gallery.airstore.io/birds.jpg')
.then(response => {
if(response.ok) {
return response.blob();
}
throw new Error('Network response was not ok.');
}).then(myBlob => {
const objectURL = URL.createObjectURL(myBlob);
this.image = objectURL;
}).catch(error => {
console.error(error);
this.image = errorImage;
});
}
} This code will:
However, this is not a good solution! This is just a hack untill #304 is resolved. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of loading it as blob
The text was updated successfully, but these errors were encountered: