diff --git a/src/content/reference/react-dom/components/img.md b/src/content/reference/react-dom/components/img.md index 4a1f45077..e288d6c73 100644 --- a/src/content/reference/react-dom/components/img.md +++ b/src/content/reference/react-dom/components/img.md @@ -4,7 +4,7 @@ title: "" -The [built-in browser `` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) lets you embed an image. +[내장 브라우저 `` 컴포넌트](https://developer.mozilla.org/ko/docs/Web/HTML/Element/img)를 사용하면 이미지를 삽입할 수 있습니다. ```js A person walking through a park @@ -16,50 +16,50 @@ The [built-in browser `` component](https://developer.mozilla.org/en-US/doc --- -## Reference {/*reference*/} +## 레퍼런스 {/*reference*/} ### `` {/*img*/} -To display an image, render the [built-in browser `` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img). +이미지를 표시하려면 [내장 브라우저 `` 컴포넌트](https://developer.mozilla.org/ko/docs/Web/HTML/Element/img)를 렌더링합니다. ```js A person walking through a park ``` -[See more examples below.](#usage) +[아래 예시를 참고하세요.](#usage) #### Props {/*props*/} -`` supports all [common element props.](/reference/react-dom/components/common#common-props) - -* `alt`: a string. Specifies alternative text for the image. Use an empty string for a purely decorative image. -* `crossOrigin`: a string. Specifies the [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use when fetching the image. The possible values are `anonymous` and `use-credentials`. -* `decoding`: a string. Suggests whether the browser should wait to decode the image before presenting other content. The possible values are `async`, `sync`, and `auto` (the default). -* `fetchPriority`: a string. Suggests a relative priority for fetching the image. The possible values are `high`, `low`, and `auto` (the default). During server rendering, `fetchPriority="low"` also prevents React from [automatically preloading the image.](#controlling-image-preloading-during-server-rendering) -* `height`: a number or string. Specifies the rendered height of the image. -* `loading`: a string. Specifies whether the browser should defer loading the image until it is near the viewport. The possible values are `eager` (the default) and `lazy`. Setting `loading="lazy"` prevents React from [automatically preloading the image.](#controlling-image-preloading-during-server-rendering) -* `onError`: an [event handler](/reference/react-dom/components/common#event-handler) function. Fires when the image fails to load. -* `onLoad`: an [event handler](/reference/react-dom/components/common#event-handler) function. Fires when the image finishes loading. Passing `onLoad` prevents React from [waiting for the image during a client-rendered View Transition update.](#waiting-for-an-image-during-a-view-transition) -* `referrerPolicy`: a string. Specifies the [referrer information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy) to send when fetching the image. -* `sizes`: a string. Specifies the image sizes for different page layouts. Used with `srcSet`. -* `src`: a string. Specifies the URL of the image. -* `srcSet`: a string. Specifies one or more candidate image sources for the browser to choose from. -* `useMap`: a string. Associates the image with a [client-side image map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map). -* `width`: a number or string. Specifies the rendered width of the image. - -#### Caveats {/*caveats*/} - -* Do not pass an empty string to `src`. It may cause the browser to request the current page again. React warns in development and omits the attribute. To render no image, omit the `` or pass `null` to `src`. -* `` cannot have children or use `dangerouslySetInnerHTML`. React throws an error if you pass either. -* `fetchPriority="low"` does not stop React from waiting for the image to load and decode during a client-rendered View Transition update. Use `loading="lazy"` or an `onLoad` handler to opt out of that behavior. +``는 모든 [공통 엘리먼트 Props](/reference/react-dom/components/common#common-props)를 지원합니다. + +* `alt`: 문자열. 이미지에 대한 대체 텍스트를 지정합니다. 순수하게 장식용인 이미지에는 빈 문자열을 사용하세요. +* `crossOrigin`: 문자열. 이미지를 가져올 때 사용할 [CORS 정책](https://developer.mozilla.org/ko/docs/Web/HTML/Attributes/crossorigin)을 지정합니다. 가능한 값은 `anonymous`와 `use-credentials`입니다. +* `decoding`: 문자열. 브라우저가 다른 콘텐츠를 표시하기 전에 이미지 디코딩을 기다려야 하는지에 대한 힌트를 지정합니다. 가능한 값은 `async`, `sync`, `auto`(기본값)입니다. +* `fetchPriority`: 문자열. 이미지를 가져올 상대적 우선순위에 대한 힌트를 지정합니다. 가능한 값은 `high`, `low`, `auto`(기본값)입니다. 서버 렌더링 중에는 `fetchPriority="low"`가 React의 [자동 이미지 프리로드](#controlling-image-preloading-during-server-rendering)도 막습니다. +* `height`: 숫자 또는 문자열. 이미지가 렌더링될 높이를 지정합니다. +* `loading`: 문자열. 브라우저가 이미지가 뷰포트에 가까워질 때까지 로드를 지연해야 하는지를 지정합니다. 가능한 값은 `eager`(기본값)와 `lazy`입니다. `loading="lazy"`를 설정하면 React의 [자동 이미지 프리로드](#controlling-image-preloading-during-server-rendering)가 적용되지 않습니다. +* `onError`: [이벤트 핸들러](/reference/react-dom/components/common#event-handler) 함수. 이미지 로드에 실패했을 때 호출됩니다. +* `onLoad`: [이벤트 핸들러](/reference/react-dom/components/common#event-handler) 함수. 이미지 로드가 완료되었을 때 호출됩니다. `onLoad`를 전달하면 클라이언트에서 렌더링되는 View Transition 업데이트 중에 React가 [이미지를 기다리지 않습니다](#waiting-for-an-image-during-a-view-transition). +* `referrerPolicy`: 문자열. 이미지를 가져올 때 보낼 [리퍼러 정보](https://developer.mozilla.org/ko/docs/Web/HTML/Element/img#referrerpolicy)를 지정합니다. +* `sizes`: 문자열. 다양한 페이지 레이아웃에 대한 이미지 크기를 지정합니다. `srcSet`과 함께 사용합니다. +* `src`: 문자열. 이미지의 URL을 지정합니다. +* `srcSet`: 문자열. 브라우저가 선택할 수 있는 하나 이상의 후보 이미지 소스를 지정합니다. +* `useMap`: 문자열. 이미지를 [클라이언트 측 이미지 맵](https://developer.mozilla.org/ko/docs/Web/HTML/Element/map)과 연결합니다. +* `width`: 숫자 또는 문자열. 이미지가 렌더링될 너비를 지정합니다. + +#### 주의 사항 {/*caveats*/} + +* `src`에 빈 문자열을 전달하지 마세요. 브라우저가 현재 페이지를 다시 요청할 수 있습니다. React는 개발 환경에서 경고하고 해당 어트리뷰트를 생략합니다. 이미지를 렌더링하지 않으려면 ``를 생략하거나 `src`에 `null`을 전달하세요. +* ``는 자식을 가질 수 없고 `dangerouslySetInnerHTML`도 사용할 수 없습니다. 둘 중 하나라도 전달하면 React는 오류를 발생시킵니다. +* `fetchPriority="low"`는 클라이언트에서 렌더링되는 View Transition 업데이트 중에 React가 이미지의 로드와 디코딩을 기다리는 것을 막지 않습니다. 이 동작을 해제하려면 `loading="lazy"` 또는 `onLoad` 핸들러를 사용하세요. --- -## Usage {/*usage*/} +## 사용법 {/*usage*/} -### Displaying an image {/*displaying-an-image*/} +### 이미지 표시하기 {/*displaying-an-image*/} -Pass the image URL to `src` and a text description to `alt`: +이미지 URL을 `src`에, 텍스트 설명을 `alt`에 전달하세요. @@ -85,15 +85,15 @@ img { -Specify `width` and `height` when you know the image dimensions so the browser can reserve space before the image loads. For a decorative image, pass `alt=""` so that screen readers ignore it. +이미지의 크기를 알고 있다면 `width`와 `height`를 지정하여 브라우저가 이미지가 로드되기 전에 공간을 확보할 수 있도록 하세요. 장식용 이미지라면 스크린 리더가 무시할 수 있도록 `alt=""`를 전달하세요. --- -### Controlling image preloading during server rendering {/*controlling-image-preloading-during-server-rendering*/} +### 서버 렌더링 중 이미지 프리로드 제어하기 {/*controlling-image-preloading-during-server-rendering*/} -During server rendering, React automatically generates a preload hint for an `` by default. This can let the browser start fetching the image before it encounters the `` in the rendered HTML. +서버 렌더링 중에 React는 기본적으로 ``에 대한 프리로드 힌트를 자동으로 생성합니다. 이를 통해 브라우저가 렌더링된 HTML에서 ``를 만나기 전에 이미지 가져오기를 시작할 수 있습니다. -Add `loading="lazy"` or `fetchPriority="low"` to an image that should not receive this hint: +이 힌트를 받지 않아야 하는 이미지에는 `loading="lazy"` 또는 `fetchPriority="low"`를 추가하세요. ```js function ProductPage() { @@ -107,31 +107,31 @@ function ProductPage() { } ``` -In this example, React generates a preload hint only for `hero.jpg`. Depending on the server API or framework, React may render the equivalent of this element: +이 예시에서 React는 `hero.jpg`에 대해서만 프리로드 힌트를 생성합니다. 서버 API나 프레임워크에 따라 React는 다음 엘리먼트에 해당하는 결과를 렌더링할 수 있습니다. ```html ``` -React may instead provide the same hint in a `Link` response header. The other two images keep their `loading` and `fetchPriority` props in the rendered HTML, but React does not generate preload hints for them. The `loading="lazy"` prop asks the browser to defer loading an image until it approaches the viewport. The `fetchPriority="low"` prop allows the image to load immediately, but tells the browser to fetch it at a lower priority. +React는 대신 `Link` 응답 헤더로 동일한 힌트를 제공할 수도 있습니다. 나머지 두 이미지는 렌더링된 HTML에서 `loading`과 `fetchPriority` props를 그대로 유지하지만, React는 이들에 대한 프리로드 힌트를 생성하지 않습니다. `loading="lazy"` prop은 브라우저에 이미지가 뷰포트에 가까워질 때까지 로드를 지연하도록 요청합니다. `fetchPriority="low"` prop은 이미지가 즉시 로드될 수 있도록 허용하면서도, 브라우저에 더 낮은 우선순위로 가져오도록 지시합니다. -React also does not automatically preload an image when it is inside a `` or `