Skip to content

Commit 966e2bd

Browse files
committed
Fix minor bug
1 parent fbf65f5 commit 966e2bd

File tree

10 files changed

+26
-25
lines changed

10 files changed

+26
-25
lines changed

projects/imagekit-angular/src/lib/directives/ik-image.directive.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ export class IKImageDirective implements OnChanges {
165165
this.config
166166
);
167167

168+
// Apply sizes attribute if provided and in responsive mode
169+
if (this.sizes && this.responsive) {
170+
this.renderer.setAttribute(this.el.nativeElement, 'sizes', this.sizes);
171+
}
172+
173+
// Apply width attribute if provided
174+
if (this.width) {
175+
this.renderer.setAttribute(this.el.nativeElement, 'width', this.width.toString());
176+
}
177+
178+
// Apply loading attribute if provided
179+
if (this.loading) {
180+
this.renderer.setAttribute(this.el.nativeElement, 'loading', this.loading);
181+
}
182+
168183
if (!this.responsive) {
169184
// Non-responsive image - just build a simple src
170185
const finalSrc = this.imagekitService.buildSrc({
@@ -206,20 +221,6 @@ export class IKImageDirective implements OnChanges {
206221
} else {
207222
this.removeSrcSet();
208223
}
209-
210-
// Apply sizes attribute if provided
211-
if (this.sizes && this.responsive) {
212-
this.renderer.setAttribute(this.el.nativeElement, 'sizes', this.sizes);
213-
}
214-
215-
// Apply width attribute if provided
216-
if (this.width) {
217-
this.renderer.setAttribute(this.el.nativeElement, 'width', this.width.toString());
218-
}
219-
220-
if (this.loading) {
221-
this.renderer.setAttribute(this.el.nativeElement, 'loading', this.loading);
222-
}
223224
}
224225

225226
private setSrc(src: string): void {

test-app/e2e/csr.spec.ts-snapshots/CSR-test-case-1-chromium.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/csr.spec.ts-snapshots/CSR-test-case-1-mobile-chrome.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/csr.spec.ts-snapshots/CSR-test-case-1-mobile-safari.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/csr.spec.ts-snapshots/CSR-test-case-1-webkit.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/ssr.spec.ts-snapshots/SSR-test-case-1-chromium.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/ssr.spec.ts-snapshots/SSR-test-case-1-mobile-chrome.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/ssr.spec.ts-snapshots/SSR-test-case-1-mobile-safari.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/e2e/ssr.spec.ts-snapshots/SSR-test-case-1-webkit.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test-app/src/app/app.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ <h2>IKImageDirective</h2>
9292
[width]="300"
9393
/>
9494

95-
<!-- Pass className to the image tag as it is -->
95+
<!-- Pass class to the image tag as it is -->
9696
<img
9797
ikSrc="/default-image.jpg"
98-
alt="Image with className"
99-
className="custom-class"
98+
alt="Image with class"
99+
class="custom-class"
100100
[height]="300"
101101
[width]="300"
102102
/>

0 commit comments

Comments
 (0)