set_post_thumbnail_size

函式
set_post_thumbnail_size ( $width = 0, $height = 0, $crop = false )
引數
  • (int) $width Image width in pixels.
    Required:
  • (int) $height Image height in pixels.
    Required:
  • (bool|array) $crop Optional. Whether to crop images to specified width and height or resize. An array can specify positioning of the crop area. Default false.
    Required:
    Default: false
相關
  • add_image_size()
定義位置
相關方法
set_post_thumbnailget_post_thumbnail_idthe_post_thumbnailhas_post_thumbnaildelete_post_thumbnail
引入
2.9.0
棄用
-

set_post_thumbnail_size: 這是一個WordPress的函式,用來設定當前文章的縮圖的大小。它通常用在主題的functions.php檔案中,用於定製文章縮圖的大小: 這個函式需要兩個引數:文章縮圖的寬度和高度。

為文章縮圖註冊一個影象尺寸。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
add_image_size( 'post-thumbnail', $width, $height, $crop );
}
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) { add_image_size( 'post-thumbnail', $width, $height, $crop ); }
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
	add_image_size( 'post-thumbnail', $width, $height, $crop );
}

常見問題

FAQs
檢視更多 >