image
画像ファイルのアップロード用フィールドです。サムネイル、アイキャッチ画像、アバターなどに使用します。
基本例
{
"name": "thumbnail",
"type": "image",
"label": "サムネイル"
} プロパティ
| プロパティ | 型 | 必須 | 説明 |
|---|---|---|---|
name | string | Yes | フィールドの識別子 |
type | "image" | Yes | "image"を指定 |
label | string | No | CMS上での表示名 |
note | string | No | 編集者向けの補足メモ |
required | boolean | No | 必須フィールドかどうか |
options | object | No | 画像の制約設定 |
optionsプロパティ
| プロパティ | 型 | 説明 |
|---|---|---|
maxSizeBytes | number | 最大ファイルサイズ(バイト) |
allowedTypes | string[] | 許可するMIMEタイプ |
aspectRatio | string | アスペクト比(例: "16:9") |
使用例
サムネイル
{
"name": "thumbnail",
"type": "image",
"label": "サムネイル",
"required": true
} サイズ制限付き
{
"name": "coverImage",
"type": "image",
"label": "カバー画像",
"options": {
"maxSizeBytes": 5242880
},
"note": "5MB以下の画像をアップロードしてください"
} 形式制限付き
{
"name": "photo",
"type": "image",
"label": "写真",
"options": {
"allowedTypes": ["image/jpeg", "image/png", "image/webp"]
},
"note": "JPEG、PNG、WebP形式のみ"
} アスペクト比指定
{
"name": "ogImage",
"type": "image",
"label": "OGP画像",
"options": {
"aspectRatio": "1.91:1",
"allowedTypes": ["image/jpeg", "image/png"]
},
"note": "OGP用の画像(1.91:1)"
} 完全な設定例
{
"name": "heroImage",
"type": "image",
"label": "ヒーロー画像",
"required": true,
"options": {
"maxSizeBytes": 2097152,
"allowedTypes": ["image/jpeg", "image/png", "image/webp"],
"aspectRatio": "16:9"
},
"note": "2MB以下、16:9の画像をアップロードしてください"
} アバター
{
"name": "avatar",
"type": "image",
"label": "アバター",
"options": {
"maxSizeBytes": 1048576,
"aspectRatio": "1:1"
},
"note": "1MB以下の正方形画像"
} 許可されているMIMEタイプ
pitcmsでデフォルトで許可されているMIMEタイプは以下の5つです。allowedTypesを指定しない場合、これらすべてが許可されます。
| MIMEタイプ | 拡張子 | 説明 |
|---|---|---|
image/jpeg | .jpg, .jpeg | JPEG画像 |
image/png | .png | PNG画像 |
image/gif | .gif | GIF画像 |
image/webp | .webp | WebP画像 |
image/svg+xml | .svg | SVG画像 |
allowedTypesで上記の中から許可する形式を絞り込むことができます。
一般的なファイルサイズ
| サイズ | バイト数 |
|---|---|
| 500KB | 512000 |
| 1MB | 1048576 |
| 2MB | 2097152 |
| 5MB | 5242880 |
| 10MB | 10485760 |
保存形式
画像のURLが文字列として保存されます。
マークダウン形式:
---
thumbnail: "https://example.com/images/thumbnail.jpg"
--- JSON形式:
{
"thumbnail": "https://example.com/images/thumbnail.jpg"
}