<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                精選圖像(有時也稱為Post Thumbnails)是表示單個Post,Page或Custom Post Type的圖像。 當您創建主題時,您可以通過多種不同的方式,在您的存檔頁面,標題或上面的一個帖子中輸出特色圖像。 支持特色圖像#啟用特色圖像支持 在“精選圖像”界面將出現在“編輯”屏幕上之前,主題必須聲明對“特色圖像”功能的支持。 通過在主題的functions.php文件中放置以下內容來聲明支持: ``` add_theme_support( 'post-thumbnails' ); ``` >[warning] 注意:要僅針對特定的帖子類型啟用特色映像,請參閱add_theme_support() ## 設置精選圖像 一旦添加了對特色圖片的支持,“精選圖像”元框將在相應的內容項目的“編輯”屏幕上顯示。 如果用戶無法看到它們,則可以在屏幕選項中啟用它。 默認情況下,精選圖像元框顯示在編輯帖子和編輯頁面屏幕的側欄中。 ## 功能參考 - add_image_size()– 注冊新圖片大小... - set_post_thumbnail_size() – 注冊文章縮略圖的圖片大小... - has_post_thumbnail() – 檢查帖子是否附加了圖片... - the_post_thumbnail() – 顯示帖子縮略圖... - get_the_post_thumbnail() – 檢索Post Thumbnail ... - get_post_thumbnail_id() – Retrieve Post Thumbnail ID… ## Image Sizes WordPress的默認圖像大小是“Thumbnail”,“Medium”,“Large”和“Full Size”(您上傳的圖像的原始大小)。 這些圖像大小可以在WordPress管理媒體面板的“設置”>“媒體”下配置。 您還可以通過傳遞具有圖像尺寸的數組來定義自己的圖像大小: ``` the_post_thumbnail(); // 沒有參數 - >; 縮略圖 the_post_thumbnail( 'thumbnail' ); // 縮略圖(默認最大150px x 150px) the_post_thumbnail( 'medium' ); // 中等分辨率(最大300px x 300px) the_post_thumbnail( 'medium_large' ); // 中等大分辨率(默認768px x無高度限制) the_post_thumbnail( 'large' ); // 大分辨率(最大640x x 640像素) the_post_thumbnail( 'full' ); // 原始圖像分辨率(未修改) the_post_thumbnail( array( 100, 100 ) ); // 其他分辨率(高,寬) ``` ## 添加自定義特色圖像大小 除了單獨使用定義圖像大小外 ``` the_post_thumbnail( array( , ) ); ``` 您可以在主題的功能文件中創建自定義的特色圖像大小,然后可以在主題的模板文件中調用。 ``` add_image_size( 'category-thumb', 300, 9999 ); // 300 pixels wide (and unlimited height) ``` 以下是在主題的functions.php文件中創建自定義精選圖像大小的示例。 ``` if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 150, 150, true ); // default Featured Image dimensions (cropped) // additional image sizes // delete the next line if you do not need additional image sizes add_image_size( 'category-thumb', 300, 9999 ); // 300 pixels wide (and unlimited height) } ``` ## 設置特色圖像輸出尺寸 用于當前Theme的functions.php文件。 您可以使用set_post_thumbnail_size()通過按比例調整圖像大小來設置默認的精選圖像大小(即不扭曲圖像): ``` set_post_thumbnail_size( 50, 50 ); // 50 pixels wide by 50 pixels tall, resize mode ``` 通過裁剪圖像(從側面或從頂部和底部)設置默認的精選圖像尺寸: ``` set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode ``` ## 精選圖片樣式 精選圖片被賦予一個類“wp-post-image”。 他們還根據顯示的縮略圖的大小獲得一個類。 您可以使用這些CSS選擇器對輸出進行調整: ``` img.wp-post-image img.attachment-thumbnail img.attachment-medium img.attachment-large img.attachment-full ``` 您還可以使用`the_post_thumbnail()`中的attribute參數給精選圖片自己的類。用“alignleft”類顯示精選圖像: ``` the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); ``` ## 默認使用 ``` // 檢查帖子或頁面是否分配有精選圖片。 if ( has_post_thumbnail() ) { the_post_thumbnail(); } ``` >[warning] 注意:要返回特色圖像以用于PHP代碼而不是顯示它,請使用: get_the_post_thumbnail() ``` // 檢查特色圖像,然后將其分配給一個PHP變量供以后使用 if ( has_post_thumbnail() ) { $featured_image = get_the_post_thumbnail(); } ``` ## 鏈接發布固定鏈接或更大的圖像 >[danger] 警報:不要在同一主題中一起使用這兩個示例。 示例1.要在特定循環中將Post Thumbnails鏈接到Post固定鏈接,請在Theme的模板文件中使用以下內容: ``` <?php if ( has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail(); ?> </a> <?php endif; ?> ``` 示例2.要將您網站上的所有Post Thumbnails鏈接到Post的固定鏈接,請將其放在當前的Theme的functions.php文件中: ``` add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 ); function my_post_image_html( $html, $post_id, $post_image_id ) { $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>'; return $html; } ``` 此示例鏈接到“large”Post Thumbnail圖像大小,必須在“循環”中使用。 ``` <?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >'; the_post_thumbnail('thumbnail'); echo '</a>'; } ?> ``` ## 源文件 ``` wp-includes/post-thumbnail-template.php ``` ## 外部資源 - 您需要了解有關WordPress 2.9的帖子圖像功能的一切 - WordPress 2.9中的post_thumbnail的終極指南 - WordPress中的新功能2.9:發布縮略圖
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看