Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n(zh-cn): Update zh from upstream #4393

Merged
merged 3 commits into from
Aug 29, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/content/docs/zh-cn/guides/images.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Astro 可以使用 API 远程获取数据,也可以显示来自其完整 URL
```astro title="src/pages/blog/MyImages.astro"
---
import { Image } from 'astro:assets';
import localBirdImage from ''../../images/subfolder/localBirdImage.png';
import localBirdImage from '../../images/subfolder/localBirdImage.png';
---
<Image src={localBirdImage} alt="一只鸟坐在蛋窝上。"/>
<Image src="/bird-public-folder.jpg" alt="A bird." width="50" height="50"/>
<Image src="/images/bird-in-public-folder.jpg" alt="A bird." width="50" height="50"/>
<Image src="https://example.com/remote-bird.jpg" alt="A bird." width="50" height="50"/>

<img src={localBirdImage.src} alt="一只鸟坐在蛋窝上。">
Expand Down Expand Up @@ -84,7 +84,7 @@ import myImage from "../assets/my_image.png"; // Image is 1600x900

目前,内置的 assets 功能不包括 `<Picture />` 组件。

相反,你可以 [使用 `getImage()` 生成图像或自定义组件](/zh-cn/guides/images/#使用-getimage-生成图像),这些组件使用 HTML 图像属性 `srcset` 和 `sizes` 或 `<picture>` 标签进行 [艺术指导或创建响应式图像](https://developer.mozilla.org/zh-CN/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images#art_direction)。
相反,你可以 [使用 `getImage()` 生成图像或自定义组件](#使用-getimage-生成图像),这些组件使用 HTML 图像属性 `srcset` 和 `sizes` 或 `<picture>` 标签进行 [艺术指导或创建响应式图像](https://developer.mozilla.org/zh-CN/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images#art_direction)。

#### 属性

Expand All @@ -99,7 +99,7 @@ import myImage from "../assets/my_image.png"; // Image is 1600x900
import { Image } from 'astro:assets';
import myImportedImage from `../assets/my-local-image.png`
---
<Image src={myImportedImage} alt="descriptive text" />
<Image src={myImportedImage} alt="descriptive text" />
```

- **`public/` 文件夹中的图像** - 使用图像相对于 `public` 文件夹的**文件路径**作为属性值:
Expand All @@ -112,7 +112,8 @@ import myImage from "../assets/my_image.png"; // Image is 1600x900
src="/images/my-public-image.png"
alt="descriptive text"
width="200"
height="150" />
height="150"
/>
```

- **远程图像** - 使用图像的**完整 URL**作为属性值:
Expand Down Expand Up @@ -215,9 +216,9 @@ const {src, ...attrs} = Astro.props;

本地图像必须从现有的 `.astro` 文件的相对路径**导入**,或者配置并使用 [导入别名](/zh-cn/guides/aliases/)。然后,你可以访问图像的 `src` 和其他属性,以在 `<img>` 标签中使用。

例如,使用图像自己的 `height` 和 `width` 属性作为默认值,以避免布局位移累计 CLS 并改善核心 Web 性能指标。
例如,使用图像自己的 `height` 和 `width` 属性,以避免布局位移累计 CLS 并改善核心 Web 性能指标。

```astro "myDog.src"
```astro "myDog.width" "myDog.height"
---
// 导入本地图像
import myDog from `../../images/pets/local-dog.jpg`
Expand Down