內容簡介
這個外掛可以讓你在 WordPress 控制台中選擇已註冊的圖片尺寸。
相容性
這個 ACF 欄位類型相容於:
* ACF 5
使用方法
啟用之後,這個外掛會在 ACF 中建立一個圖片尺寸欄位類型。這個欄位類型會將所有已註冊的圖片尺寸列在欄位群組中的下拉選單中。
要在自定義模板中使用這個欄位,你需要使用下列程式碼:
$my_image_id = get_field('my_image_id'); // ACF Image 回傳類型設定為 ID,此為示範
$my_image_size = get_field('my_image_size'); // 所選擇的圖片尺寸(例如:large)
echo wp_get_attachment_image( $my_image_id, $my_image_size ); // 基於 ID 和所選的圖片尺寸輸出圖片。
外掛標籤
開發者團隊
② 後台搜尋「Advanced Custom Fields: Image Size Select Field」→ 直接安裝(推薦)
原文外掛簡介
Field to select registered image sizes within the WordPress dashboard.
Compatibility
This ACF field type is compatible with:
* ACF 5
How to Use
Once activated, this plugin will create a Image Size field type in ACF. This field type will list all registered field types as a drop down within the field group.
To use this field within your custom templates you will use the following code:
$my_image_id = get_field('my_image_id'); // ACF Image return type set to ID for this demo
$my_image_size = get_field('my_image_size'); // The selected image size (eg. large)
echo wp_get_attachment_image( $my_image_id, $my_image_size ); // Output the image based on the ID, and the Image Size selected.
