-
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
Base64 image cannot access in html when set image URL #462
Comments
That should be possible. |
Base64 is loading perfectly when I set my image URL(which returns base64 string by my backend service) to [lazyload] property. I want to get that loaded base64 string to use in my other service. Is it possible? |
I guess so, here is an example of using a base 64 image in a component: https://codesandbox.io/s/lazy-load-image-with-base-64-image-gml2t?file=/src/app/app.component.ts It should just work ;) |
Nope. This is not what I'm saying. This is really working well. I need to get the base 64 string which returns to tag. <img [lazyLoad]="https://abcd.com/img/1" |
So in your case import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes } from 'ng-lazyload-image';
import { AppComponent } from './app.component';
class LazyLoadImageHooks extends IntersectionObserverHooks {
loadImage({ imagePath }: Attributes) {
return fetch(imagePath).then(res => res.text());
}
}
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, LazyLoadImageModule.forRoot(LazyLoadImageHooks)],
bootstrap: [AppComponent],
})
export class MyAppModule {} |
Nope. I want to access the base64 in HTML. |
Do you mean something like this: @Component({
selector: 'image',
template: `<image [lazyLoad]="base64image | async">`,
})
class ImageComponent {
base64image = fetch('https://abcd.com/img/1').then(r => r.text());
} Otherwise, I need a small project where you can reproduce the issue. |
I have a problem accessing the loaded base4 image in the template when I set URL to [lazyload] attribute. Is there any way of doing that?
The text was updated successfully, but these errors were encountered: