Skip to content

Commit 71a98a4

Browse files
committed
Fix minor bugs
1 parent fbf65f5 commit 71a98a4

File tree

10 files changed

+28
-25
lines changed

10 files changed

+28
-25
lines changed

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ 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+
} else {
172+
this.renderer.removeAttribute(this.el.nativeElement, 'sizes');
173+
}
174+
175+
// Apply width attribute if provided
176+
if (this.width) {
177+
this.renderer.setAttribute(this.el.nativeElement, 'width', this.width.toString());
178+
}
179+
180+
// Apply loading attribute if provided
181+
if (this.loading) {
182+
this.renderer.setAttribute(this.el.nativeElement, 'loading', this.loading);
183+
}
184+
168185
if (!this.responsive) {
169186
// Non-responsive image - just build a simple src
170187
const finalSrc = this.imagekitService.buildSrc({
@@ -206,20 +223,6 @@ export class IKImageDirective implements OnChanges {
206223
} else {
207224
this.removeSrcSet();
208225
}
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-
}
223226
}
224227

225228
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)