Skip to content

Commit e4c8bb8

Browse files
committed
refactor: move URL creation to separate methodwith params
1 parent 26cb9b4 commit e4c8bb8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

sdk/lib/src/imagekitio-angular/ik-image/ik-image.component.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class IkImageComponent implements AfterViewInit, OnInit {
2020
}
2121

2222
ngOnInit(): void {
23-
this.setUrl();
23+
this.setUrl(this.src, this.path, this.transformation, this.lqip);
2424
}
2525

2626
ngAfterViewInit() {
@@ -36,18 +36,17 @@ export class IkImageComponent implements AfterViewInit, OnInit {
3636
imageObserver.observe(this.el.nativeElement);
3737
}
3838

39-
setUrl() {
40-
if (this.src) {
41-
this.url = this.imagekit.ikInstance.url({ src: this.src, transformation: this.transformation, transformationPosition: "query" });
42-
} else if (this.path) {
43-
this.url = this.imagekit.ikInstance.url({ path: this.path, transformation: this.transformation });
39+
setUrl(src, path, transformation, lqip) {
40+
if (src) {
41+
this.url = this.imagekit.ikInstance.url({ src: src, transformation: transformation, transformationPosition: "query" });
42+
} else if (path) {
43+
this.url = this.imagekit.ikInstance.url({ path: path, transformation: transformation });
4444
} else {
4545
throw new Error('Missing src / path during initialization!');
4646
}
4747

48-
if (this.lqip !== undefined && this.lqip.active === true) {
49-
const { quality } = this.lqip;
50-
this.lqipUrl = this.lqipload(quality);
48+
if (lqip !== undefined && lqip.active === true) {
49+
this.lqipUrl = this.lqipload(lqip.quality);
5150
}
5251
}
5352

0 commit comments

Comments
 (0)