> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/blocks/insert-images.md).

# 画像

ページに画像や画像ギャラリーを追加し、ダークモード用の画像バリエーションを追加したり、必要に応じて画像のサイズ変更や配置ができます

ページに画像を挿入し、そのサイズを選び、左・中央・右のどれに揃えるかを指定できます。必要に応じて、画像ブロックに代替テキストおよび/またはキャプションを追加することもできます。

{% hint style="info" %}
**ヒント:** アクセシビリティのため、画像には代替テキストを設定することをおすすめします。
{% endhint %}

### 画像ブロックの例 <a href="#example-of-an-image-block" id="example-of-an-image-block"></a>

<div align="center"><figure><img src="https://images.unsplash.com/photo-1446776709462-d6b525c57bd3?crop=entropy&#x26;cs=srgb&#x26;fm=jpg&#x26;ixid=M3wxOTcwMjR8MHwxfHNlYXJjaHwyfHxzcGFjZXxlbnwwfHx8fDE3MzMxOTY5NTR8MA&#x26;ixlib=rb-4.0.3&#x26;q=85" alt="A photograph taken from space looking back towards Earth. A satellite is in the foreground, and in the background is an ocean-covered part of our planet with patchy clouds."><figcaption><p>キャプション付きの画像ブロックの例</p></figcaption></figure></div>

### 画像をアップロードする

コンテンツに画像を追加する方法は2つあります：

1. ファイル管理システムから画像をページ上の空のブロックへ直接ドラッグ＆ドロップします。
2. [画像ブロックを追加](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/blocks.md#inserting-a-new-content-block) してページに配置し、 **画像を選択** ウィンドウ右側に表示されるサイドパネルを使用します。

2つ目の手順では、ファイルをアップロードする、以前アップロードしたファイルを選択する、画像のURLを貼り付ける、または組み込みの検索機能を使って [Unsplash](https://unsplash.com/) から画像を追加する方法を選べます。

{% hint style="warning" %}
GitBookでは、1ファイルあたり最大100MBまでの画像をアップロードできます。
{% endhint %}

セクション内のアセット総数に設定上の上限はありませんが、GitBookは悪用があった場合にアカウントをブロックする権利を留保します。アップロード上限を超えるファイルは、Google DriveやDropboxのようなサービスに保存し、ページからリンクしてください。

アニメーションGIFは1ファイルあたり200フレームまでです。GIFを含む大きなファイルはページの読み込みを遅くするため、可能な限り大きなファイルを直接アップロードするのは避けてください。

#### 画像ギャラリーを作成する

画像ブロックに複数の画像を追加すると、ギャラリーが作成されます。作成するには、ブロックの **オプションメニュー** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture> を開き、 **画像を追加…** を選択して、もう一度 **画像を選択** サイドパネルを開きます。

ギャラリーから画像を削除するには、削除する画像の **編集メニュー** <picture><source srcset="broken://files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d28f11ed4dfafb06aa9c6ae92db8017d94014317%2F25_01_10_edit_icon_light.svg?alt=media" alt=""></picture> を開き、 **Delete ⌫** キーを押します。

### ライトモードとダークモード用の画像を追加する <a href="#light-and-dark-mode" id="light-and-dark-mode"></a>

公開サイトのライトモード版とダークモード版に、それぞれ別の画像を設定できます。GitBookは、訪問者がどちらのモードを使用しているかに応じて、適切な画像を自動的に表示します。

ダークモード用の画像を追加するには、画像にカーソルを合わせて、 **編集メニュー** <picture><source srcset="broken://files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d28f11ed4dfafb06aa9c6ae92db8017d94014317%2F25_01_10_edit_icon_light.svg?alt=media" alt=""></picture> を開き、 **画像を置き換え** <picture><source srcset="broken://files/B8EhRVkFXw7nB8Q01UEZ" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-058c44f9175073421beb38f54db046e0f48de843%2F25_01_10_replace_image_icon_light.svg?alt=media" alt="The Replace image icon in GitBook"></picture>.

をクリックします。ドロップダウンメニューから **ダークモード用の画像を追加**を選択します。設定後は、この同じメニューからどちらの画像も置き換えられます。

{% hint style="warning" %}
**注:** GitBookは現在、ページカバーや [カード](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/blocks/cards.md).
{% endhint %}

### GitHub/GitLab Syncによるライトモードとダークモードの画像 <a href="#light-and-dark-mode-through-github-gitlab-sync" id="light-and-dark-mode-through-github-gitlab-sync"></a>

の画像カバーなど、一部のケースではライトモードとダークモードの画像に対応していません。HTML構文を使えば、Markdownにもライトモードとダークモードの画像を追加できます（`<picture>` と `<source>`).

ブロック画像には、内部に `<figure>` HTML要素を使い、その中に `<picture>` と `<source>` を記述します:

```html
前のテキスト

<figure>
  <picture>
    <source
      srcset="
        https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png
      "
      media="(prefers-color-scheme: dark)"
    />
    <img
      src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png"
      alt="GitHubロゴ"
    />
  </picture>
  <figcaption>キャプションテキスト</figcaption>
</figure>

後のテキスト
```

インライン画像（テキストと同じ行に表示される画像）には、内部に `<picture>` HTML要素を使い、その中に `<source>` を記述します:

```html
画像の前のテキスト
<picture
  ><source
    srcset="
      https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png
    "
    media="(prefers-color-scheme: dark)" />
  <img
    src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png"
    alt="GitHubロゴ"
/></picture>
と画像の後のテキスト
```

{% hint style="warning" %}
**注:** まだ対応していません [GitHub専用の構文](https://github.blog/changelog/2021-11-24-specify-theme-context-for-images-in-markdown/) 次のいずれかを使用します： `#gh-dark-mode-only` または `#gh-light-mode-only`.
{% endhint %}

### サイズ変更

画像のサイズを変更するには、画像にカーソルを合わせて **編集メニュー** <picture><source srcset="broken://files/kN09oTFtAuyaxNIwWuCt" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d28f11ed4dfafb06aa9c6ae92db8017d94014317%2F25_01_10_edit_icon_light.svg?alt=media" alt=""></picture>を開きます。 **サイズ** ボタンをクリックし、表示されるオプションから画像のサイズを選択します。

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-3b8b303d26529bb63609ef087c19c9c9815dda05%2F25_12_10_image_resizing%402x.png?alt=media" alt="A GitBook screenshot showing how to resize an image"><figcaption><p>画像のサイズを変更する</p></figcaption></figure>

* **小** – 画像サイズの25%
* **中** – 画像サイズの50%
* **大** – 画像サイズの75%
* **幅に合わせる** – サイズ指定をすべて解除し、元のサイズで表示します。ただし、大きな画像は最大幅 **735** **ピクセル** に制限されます。

画像がエディタより横幅が広い場合、GitBookは画像の幅をエディタの幅に制限し、サイズ変更はその制限に基づいて行われます。

{% hint style="info" %}
**注：** 画像ギャラリー内の画像のサイズを変更した場合、個別の画像のサイズを変更した場合とは結果が異なることがあります。
{% endhint %}

### Git Syncによる画像のサイズ変更

画像のサイズをより細かく制御したい場合は、GitHubまたはGitLabでMarkdownを使って正確なサイズを指定できます。

画像をエクスポートする際は、HTMLタグ `<img/>`を使用します。仕様に従い、画像の寸法は `width` と `height` 属性で指定できます。これらの属性に指定できるのは、ピクセル単位の値、または数値と `%` 記号を組み合わせた値のみです。\
\
画像の寸法を指定する有効な形式は次のとおりです。\
\
`<img width="100" />` 画像の幅を100ピクセルに設定します\
`<img width="100%" />` 画像を元のサイズで表示します（ただし、エディターのサイズによる制限を受けます）

### 画像の配置

デフォルトでは、画像ブロックは画像を中央揃えで原寸大表示します。

画像の配置を変更するには、ブロックの **オプションメニュー** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture> を開き、配置を選択します。この設定は、エディターより幅が狭い画像、または [サイズを変更した](#resizing).

### 画像の枠線

画像ブロックに枠線を追加すると、画像に統一感を持たせ、周囲のコンテンツと視覚的に区別できます。

<div data-with-frame="true"><figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-61de0988bf7e96f4e2bcc8e85c4f70bca626f781%2F25_10_06_image_frame_demo%402x.jpg?alt=media" alt="A black and white photograph of a lone figure walking across a stark white landscape"><figcaption><p>枠線付きの画像にはキャプションを付けることができ、キャプションの背後に控えめなグリッドが表示されます。</p></figcaption></figure></div>

画像に枠を付けるには、画像にカーソルを合わせ、ブロックの **オプションメニュー** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt=""></picture> を開いて、 **枠を表示** の切り替えをオンにします。

{% hint style="info" %}
**補足：** ブロック内の単一画像にのみ枠を付けられます。複数の画像を含む画像ブロックやインライン画像には枠を付けられません。
{% endhint %}

### Markdownでの表現

```markdown
//シンプルブロック
![](https://gitbook.com/images/gitbook.png)

//キャプション付きブロック
![GitBookロゴ](https://gitbook.com/images/gitbook.png)

//代替テキスト付きブロック

<figure><img src="https://gitbook.com/images/gitbook.png" alt="GitBookロゴ"></figure>

//キャプションと代替テキスト付きブロック

<figure><img src="https://gitbook.com/images/gitbook.png" alt="GitBookロゴ"><figcaption><p>GitBookロゴ</p></figcaption></figure>

// 枠線付き画像のブロック

<div data-with-frame="true"><img src="https://gitbook.com/images/gitbook.png" alt="GitBookロゴ"></div>

//キャプション付き、ダークモードとライトモードで異なる画像を持つブロック

<figure>
  <picture>
    <source srcset="https://user-images.githubusercontent.com/3369400/139447912-e0f43f33-6d9f-45f8-be46-2df5bbc91289.png" media="(prefers-color-scheme: dark)">
    <img src="https://user-images.githubusercontent.com/3369400/139448065-39a229ba-4b06-434b-bc67-616e2ed80c8f.png" alt="GitHubロゴ">
  </picture>
  <figcaption>キャプションテキスト</figcaption>
</figure>
```

### 画像が読み込まれないのはなぜですか？

「画像を読み込めませんでした」というエラーは、画像が元の場所で変更または削除されたことを意味します。URLを使って画像を埋め込み、アップロードしていない場合、GitBookはそのURLに依存します。画像が元の場所から移動または消えると、ページに表示されなくなります。

解決するには、画像をGitBookに直接アップロードするか、画像の場所が変わった場合はURLを更新してください。また、あるセクションから別のセクションへ画像をコピーした場合にもこのエラーが表示されることがあります。各セクションには独自のファイルディレクトリがあるためです。新しいセクションで画像を再アップロードしてください。

セクションにアップロードしたすべてのファイルは、目次上部の **ライブラリ** タブで、 **ページ** の隣にある項目から確認できます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/blocks/insert-images.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
