WordPress debugging thumbnails of the relevant PHP functions using parsing, WordPress thumbnail
The_post_thumbnail
The_post_thumbnail is mainly used in WordPress to print the thumbnails set in the article, and the Get_the_post_thumbnail function can return the HTML code you need as a string.
Use of the The_post_thumbnail function
The_post_thumbnail ($size, $attr)
function parameters
- $size means that the thumbnail type you want is the default ' Post-thumbnail ', which is the featured image
- $attr the attribute settings in the image img tag.
the_post_thumbnail function Declaration
/** * Display Post Thumbnail. * * @since 2.9.0 * * @param int $size Optional. Image size. Defaults to ' Post-thumbnail ', which theme sets using Set_post_thumbnail_size ($width, $height, $crop _flag);. * @param string|array $attr Optional. Query string or array of attributes. */function the_post_thumbnail ($size = ' Post-thumbnail ', $attr = ') {echo get_the_post_thumbnail (null, $size, $attr); }get_the_post_thumbnail function declaration * Retrieve post thumbnail. * * @since 2.9.0 * * @param int $post _id Optional. The Post ID. * @param string $size Optional. Image size. Defaults to ' Post-thumbnail '. * @param string|array $attr Optional. Query string or array of attributes. */function get_the_post_thumbnail ($post _id = null, $size = ' Post-thumbnail ', $attr = ') {$post _id = (Null = = = $post _i d)? GET_THE_ID (): $post _id; $post _thumbnail_id = get_post_thumbnail_id ($post _id); $size = apply_filters (' post_thumbnail_size ', $size); if ($post _thumbnail_id) {do_action (' begin_fetch_post_thumbnail_html '),$post _id, $post _thumbnail_id, $size); For "Just in time" filtering of all of Wp_get_attachment_image () ' s filters if (In_the_loop ()) Update_post_thumbnail_ Cache (); $html = Wp_get_attachment_image ($post _thumbnail_id, $size, False, $attr); Do_action (' end_fetch_post_thumbnail_html ', $post _id, $post _thumbnail_id, $size); } else {$html = ';} return apply_filters (' post_thumbnail_html ', $html, $post _id, $post _thumbnail_id, $size, $attr);
Set_post_thumbnail_size
The Set_post_thumbnail_size function is a simple application of the Add_image_size function, which is a function of setting the feature image size in WordPress. In order to better highlight the use of featured images, WordPress since the beginning of the 2.9.0 version, there is this function.
Use of the Set_post_thumbnail_size function
Similar to the use of the Add_image_size function, except that the function is set only for featured images.
Set_post_thumbnail_size ($width, $height, $crop)
Detailed parameters
- $width Image Width
- $height Image Height
- $crop whether to trim the image according to aspect
Instance
Set_post_thumbnail_size (100,0,true);
Note: When the height and width of any one is 0 o'clock, WP will automatically adapt to another value for thumbnail generation work.
function declaration
/** * Registers an image size for the post thumbnail * * @since 2.9.0 */function set_post_thumbnail_size ($width = 0, $hei ght = 0, $crop = False) {add_image_size (' post-thumbnail ', $width, $height, $crop);
Articles you may be interested in:
- Analysis of correlation function used in WordPress development for caption Display
- configuration resolves the WordPress path in the Nginx server does not automatically add a slash problem
- The PHP function used in WordPress to get the search form is parsed
- Use the Wp_count_posts function in WordPress to count the number of articles
- PHP functions for invoking comment templates and looping out comments in WordPress
- A detailed description of the use of classification function wp_list_categories in WordPress
- WordPress restricts non-admin users to comment only once after the article
- Detailed PHP functions for creating and adding filters in WordPress
- A detailed description of the use of Wp_title () functions in WordPress development
http://www.bkjia.com/PHPjc/1089580.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089580.html techarticle WordPress Debugging thumbnails of the relevant PHP functions using parsing, wordpress thumbnail the_post_thumbnail the_post_thumbnail in WordPress mainly used to print the text set in the thumbnail image, ...