Description
Set the default Featured Image (formerly Post Thumbnail) dimensions. To register additional image sizes for Featured Images use: add_image_size().
Note: To enable featured images, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file. See also Post Thumbnails.
Usage
<?php set_post_thumbnail_size( $width, $height, $crop ); ?>
Parameters
$width
(int) (optional) The post thumbnail width in pixels.
Default: 0
$height
(int) (optional) The post thumbnail height in pixels.
Default: 0
$crop
(boolean) (optional) Crop the image or not. False - Soft proportional crop mode ; True - Hard crop mode.
Default: false
Examples
Default Usage
To be used in the current theme's functions.php file.
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 );
}
Crop Mode
Set the default Post Thumbnail size by resizing the image proportionally (that is, without distorting it):
set_post_thumbnail_size( 50, 50 ); // 50 pixels wide by 50 pixels tall, resize mode
Set the default Post Thumbnail size by cropping the image (either from the sides, or from the top and bottom):
set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode
Change Log
Since 2.9
Source File
set_post_thumbnail_size() is located in wp-includes/media.php.
Related
Post Thumbnails: has_post_thumbnail(), the_post_thumbnail(), get_post_thumbnail_id(), get_the_post_thumbnail(), add_image_size(), set_post_thumbnail_size()
Monday, June 9, 2014
Function Reference/set post thumbnail size
20Me Reviews
8:58 PM
Translate
Được Quan Tâm
-
Ảnh chỉ mang tính minh họa Đầu tiên : Các bạn đăng nhập vào http://Blogger.com Bước 2 : Vào trang quản lý nhấp vào phần Bố Cục ...
-
BÀI VIẾT CÓ HÌNH ẢNH MINH HỌA, BẠN CHỜ LOAD ẢNH XONG RỒI HÃY LÀM! Bước 1: Click chuột trái đến số trang bạn cần đánh, ở đây mình lấy ví dụ l...
-
TITLE là phần rất quan trọng trong 1 bài viết, là cái đầu tiên mà khách hàng nhìn thấy khi tìm kiếm trên google. Tiêu đề càng gắn gọn, càng ...
-
Nokia C1 là một trong những điện thoại chạy hệ điều hành Android đầu tiên của Nokia, sau khi hợp đồng giữa hãng và Microsoft chấm dứt. Noki...
-
Hiện nay có rất nhiều các mẫu đơn xin việc được in sẵn và bán rất nhiều trong các tiệm photo, tiệm tạp hóa, cũng như sự phát triển của inter...
-
When the industry is nervously awaited Galaxy S7 at the MWC 2016, but the first rumors about the Galaxy Note 6 has emerged in China. Inform...
-
There have been many articles comparing Android and iOS devices, after several years, as the two platforms together, but there are still And...
-
Korean technology companies will enable the new smartphone duo placed before the date of 21/2. In addition to price competition, the next ge...
-
Làm thế nào để tạo chữ trong suốt trong photoshop cs6 đẹp và độc . Kỹ năng tạo chữ trong suốt trong ps không phải ai cũng biết và bạn là ngư...
0 nhận xét :