好的,我感到困惑。在Wordpress中设置图像大小。图像大小,slu and和名称正在注册。我无休止地重写了缩略图。我最初写的缩略图确实有一个输出似乎包括位置。但不是我在我的功能中列出的位置。我一遍又一遍地改变了立场而没有改变。我在这里错过了什么?提前谢谢!
<?php
add_image_size( 'mobile-accordion-tab', 650, 115, array( 'left', 'top' ) ); // Image crop for mobile accordions
add_image_size ('offers-nav', 322, 322, array('center', 'center' ) ); // Image crop for stateoffers nav
add_image_size ('offers-accordion', 651, 365 ); // Image crop for state offers accordion
add_image_size( 'listicle-thumb', 470, 314, array( 'center', 'center' ) ); // Image crop for listicle post in two column slider
add_image_size ('resorts-accordion', 225, 340, array( 'left', 'center' ) ); // Image crop for resorts horizontal accordion
add_image_size ('header-logo', 110, 65 ); // Image size for header logo
add_image_size ('footer-logo', 135, 77 ); // Image size for footer logo
add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );
function custom_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'mobile-accordion-tab' => 'Mobile Accoridon Tab',
'offers-nav' => 'Offers State Nav Item',
'offers-accordion' => 'Offers State Accordion',
'listicle-thumb' => 'Listicle Thumbnail',
'resorts-accordion' => 'Horizontal Accordion Resort Image',
'footer-logo' => 'Footer Logo',
'header-logo' => 'Header Logo',
);
return array_merge( $sizes, $custom_sizes );
}
答案 0 :(得分:0)
根据规范here,$crop
参数的默认值为false
。我认为我们应该给它一个true
值。
请尝试以下代码:
<?php
add_image_size( 'mobile-accordion-tab', 650, 115, array( 'left', 'top' ), true ); // Image crop for mobile accordions
add_image_size ('offers-nav', 322, 322, array('center', 'center' ), true ); // Image crop for stateoffers nav
add_image_size ('offers-accordion', 651, 365, true ); // Image crop for state offers accordion
add_image_size( 'listicle-thumb', 470, 314, array( 'center', 'center' ), true ); // Image crop for listicle post in two column slider
add_image_size ('resorts-accordion', 225, 340, array( 'left', 'center' ), true ); // Image crop for resorts horizontal accordion
add_image_size ('header-logo', 110, 65, true ); // Image size for header logo
add_image_size ('footer-logo', 135, 77, true ); // Image size for footer logo
add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );
function custom_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'mobile-accordion-tab' => 'Mobile Accoridon Tab',
'offers-nav' => 'Offers State Nav Item',
'offers-accordion' => 'Offers State Accordion',
'listicle-thumb' => 'Listicle Thumbnail',
'resorts-accordion' => 'Horizontal Accordion Resort Image',
'footer-logo' => 'Footer Logo',
'header-logo' => 'Header Logo',
);
return array_merge( $sizes, $custom_sizes );
}