mirror of
https://github.com/angular/angular.git
synced 2026-12-06 05:09:14 -05:00
As an ongoing effort to stabilize the NgOptimizedImage API before existing the Developer Preview, this commit renames the `rawSrc` attribute used for the NgOptimizedImage selector matching to `ngSrc`. The `rawSrcset` is also renamed to `ngSrcset` for consistency. The motivation for this change is to align the attribute name better with other built-in directives, such as `ngFor`, `ngIf`, `ngClass`, `ngStyle`, etc. Note: this is technically a breaking change, but since the NgOptimizedImage directive is in the Developer Preview mode, we land the change in a patch branch. PR Close #47362
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {NgOptimizedImage, provideImgixLoader} from '@angular/common';
|
|
import {Component} from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'basic',
|
|
styles: [`
|
|
h1 {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
main {
|
|
border: 1px solid blue;
|
|
margin: 16px;
|
|
padding: 16px;
|
|
}
|
|
|
|
.spacer {
|
|
height: 3000px;
|
|
}
|
|
|
|
main img {
|
|
width: 100%;
|
|
height: auto;
|
|
}
|
|
`],
|
|
template: `
|
|
<h1>
|
|
<img ngSrc="a.png" width="50" height="50" priority ngSrcset="1x, 2x">
|
|
<span>Angular image app</span>
|
|
</h1>
|
|
<main>
|
|
<div class="spacer"></div>
|
|
<img ngSrc="hermes2.jpeg" ngSrcset="100w, 200w, 1000w, 2000w" width="1791" height="1008">
|
|
</main>
|
|
`,
|
|
standalone: true,
|
|
imports: [NgOptimizedImage],
|
|
providers: [provideImgixLoader('https://aurora-project.imgix.net')],
|
|
})
|
|
export class PlaygroundComponent {
|
|
}
|