[WordPress] 外掛分享: Theme Image Block

首頁外掛目錄 › Theme Image Block
全新外掛
安裝啟用
尚無評分
26 天前
最後更新
問題解決
WordPress 6.8+ PHP 7.4+ v1.1.1 上架:2025-12-15

內容簡介

**總結:**
Theme Image Block 外掛允許您從您的主題中註冊圖像並將其作為區塊提供在WordPress編輯器中使用。這對於標誌、圖示和其他與主題設計系統相關的圖像非常有用。

### 問題與解答:

1. 如何註冊主題圖像?
- 使用HappyPrime\ThemeImageBlock\register_theme_image()來註冊主題圖像。

2. 哪些時機最適合註冊主題圖像?
- 最好在init或after_setup_theme動作時註冊主題圖像。

3. 如何設定主題圖像風格?
- 使用HappyPrime\ThemeImageBlock\register_theme_image_style()來註冊主題圖像風格。

4. 在何時最適合註冊主題圖像風格?
- 最好在init或after_setup_theme動作時註冊主題圖像風格。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Theme Image Block」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

The Theme Image Block plugin allows you to register images from your theme and make them available as blocks in the WordPress editor. This is useful for logos, icons, and other images that are part of your theme’s design system.
Usage
Registering Theme Images
Theme images should be registered using HappyPrime\ThemeImageBlock\register_theme_image(). This is likely best done on the init or after_setup_theme action.
HappyPrime\ThemeImageBlock\register_theme_image(
'happy-prime-logo',
[
'title' => 'Happy Prime Logo',
'description' => 'The Happy Prime logo.',
'alt' => 'Happy Prime',
'path' => 'images/happy-prime-logo.svg',
'width' => '300',
'height' => '',
'variations' => [
'small' => [
'path' => 'images/happy-prime-logo-small.svg',
'width' => '100',
'height' => '100',
],
'medium' => [
'path' => 'images/happy-prime-logo-medium.svg',
'width' => '200',
'height' => '200',
],
'large' => [
'path' => 'images/happy-prime-logo-large.svg',
'width' => '300',
'height' => '300',
],
],
'sizes' => '(max-width: 600px) 100vw, 300px',
]
);

Registering Theme Image Styles
Theme image styles should be registered using HappyPrime\ThemeImageBlock\register_theme_image_style(). This is likely best done on the init or after_setup_theme action.
HappyPrime\ThemeImageBlock\register_theme_image_style(
'hero',
[
'name' => 'Hero',
'width' => 'clamp(10rem, 100vw, 60rem)',
'height' => 'auto',
]
);

延伸相關外掛

文章
Filter
Apply Filters
Mastodon