diff --git a/packages/common/src/directives/ng_optimized_image.ts b/packages/common/src/directives/ng_optimized_image.ts index 742e44cd872..fd88ec1e358 100644 --- a/packages/common/src/directives/ng_optimized_image.ts +++ b/packages/common/src/directives/ng_optimized_image.ts @@ -94,12 +94,6 @@ export class NgOptimizedImage implements OnInit { return this._height; } - /** - * Function that takes the name of the image, its width, and a quality %, - * then turns it into a valid image CDN URL. - */ - @Input() loader?: (config: ImageLoaderConfig) => string; - /** * Get a value of the `src` if it's set on a host element. * This input is needed to verify that there are no `src` and `raw-src` provided @@ -114,9 +108,6 @@ export class NgOptimizedImage implements OnInit { } getRewrittenSrc(): string { - // If a loader is provided as an input - use it, otherwise fall back - // to the loader configured globally using the `IMAGE_LOADER` token. - const imgLoader = this.loader ?? this.imageLoader; const imgConfig = { src: this.rawSrc, // TODO: if we're going to support responsive serving, we don't want to request the width @@ -124,7 +115,7 @@ export class NgOptimizedImage implements OnInit { // The width would require pre-processing before passing to the image loader function. width: this.width, }; - return imgLoader(imgConfig); + return this.imageLoader(imgConfig); } } diff --git a/packages/common/test/directives/ng_optimized_image_spec.ts b/packages/common/test/directives/ng_optimized_image_spec.ts index 9cafd3dcdc1..9e9a5b5ca04 100644 --- a/packages/common/test/directives/ng_optimized_image_spec.ts +++ b/packages/common/test/directives/ng_optimized_image_spec.ts @@ -38,22 +38,6 @@ describe('Image directive', () => { expect(img.src.endsWith('/path/img.png?w=150')).toBeTrue(); }); - it('should use an image loader from inputs over the one provided via `IMAGE_LOADER` token', - () => { - const imageLoader = (config: ImageLoaderConfig) => - `${config.src}?w=${config.width}&source=IMAGE_LOADER`; - setupTestingModule({imageLoader}); - - const template = - ''; - const fixture = createTestComponent(template); - fixture.detectChanges(); - - const nativeElement = fixture.nativeElement as HTMLElement; - const img = nativeElement.querySelector('img')!; - expect(img.src.endsWith('/path/img.png?w=150&source=component')).toBeTrue(); - }); - describe('setup error handling', () => { it('should throw if both `src` and `raw-src` are present', () => { setupTestingModule(); @@ -79,9 +63,6 @@ describe('Image directive', () => { template: '', }) class TestComponent { - cmpImageLoader = (config: ImageLoaderConfig) => { - return `${config.src}?w=${config.width}&source=component`; - } } function setupTestingModule(config?: {imageLoader: ImageLoader}) {