Php 防止旧缩略图重新调整大小?

Php 防止旧缩略图重新调整大小?,php,image,Php,Image,如何防止第一篇文章的后续文章调整大小?理想情况下,所有图像应为590px宽,而不考虑后期顺序 在我看来,这段代码可能与此有关,但不管我将宽度更改为什么,问题仍然存在 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 590, 275, true ); // 590 pixels wide by 275 pixels tall, hard crop mode add_image_size( 'following-

如何防止第一篇文章的后续文章调整大小?理想情况下,所有图像应为590px宽,而不考虑后期顺序

在我看来,这段代码可能与此有关,但不管我将宽度更改为什么,问题仍然存在

add_theme_support( 'post-thumbnails' );  
set_post_thumbnail_size( 590, 275, true ); // 590 pixels wide by 275 pixels tall, hard crop mode
add_image_size( 'following-post-thumbnails', 250, 200, true ); // 250 pixels wide by 200 pixels tall, hard crop mode
Full functions.php

<?php


if ( ! isset( $content_width ) )
    $content_width  = '590';


/**
* Add Menu Support
**/

add_theme_support('automatic-feed-links');
register_nav_menu('main', 'Main Nav');

/**
* Add editor style - recommended according to Theme-Check
**/
add_editor_style('editor-style.css');


/**
* Add custom background with custom background colour fix 
* as shown here: http://devpress.com/blog/custom-background-fix-for-theme-developers/
**/

add_custom_background( 'grisaille_custom_background_callback' );

function grisaille_custom_background_callback() {

    /* Get the background image. */
    $image = get_background_image();

    /* If there's an image, just call the normal WordPress callback. We won't do anything here. */
    if ( !empty( $image ) ) {
        _custom_background_cb();
        return;
    }

    /* Get the background color. */
    $color = get_background_color();

    /* If no background color, return. */
    if ( empty( $color ) )
        return;

    /* Use 'background' instead of 'background-color'. */
    $style = "background: #{$color};";

?>
<style type="text/css">body { <?php echo trim( $style ); ?> }</style>
<?php

}

/**
* Add custom header
**/

define('HEADER_TEXTCOLOR', '334759');
define('HEADER_IMAGE', ''); // %s is the template dir uri
define('HEADER_IMAGE_WIDTH', 960); // use width and height appropriate for your theme
define('HEADER_IMAGE_HEIGHT', 200);

// gets included in the site header

function grisaille_header_style() {

    ?><style type="text/css">
        #site-title {
            background: url(<?php header_image(); ?>) 0 0 no-repeat;
            min-height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
            margin: 20px 0;          
        }
        #site-title h1 a {
            color:#<?php header_textcolor(); ?> ;
            min-height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
        }
        #site-description {
            color:#<?php header_textcolor(); ?> ;
        }
        <?php if ( 'blank' == get_header_textcolor() ) { ?>
        #site-title h1 {
            padding: 0;
        }
        #site-title h1 a  {
            display:block;
            text-indent:-99999px;
        }
        #site-description {
            display: none;
            text-indent:-99999px;
        }

<?php } ?>
</style>
<?php
}
// gets included in the admin header
function grisaille_admin_header_style() {
    ?>
        <style type="text/css">
            @font-face {
            font-family: 'WoodenNickelBlackRegular';
    src: url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.eot?') format('eot'),
         url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.woff') format('woff'),
         url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.ttf') format('truetype'),
         url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.svg#webfontDYhQeecV') format('svg');
    font-weight: normal;
    font-style: normal;
}

        #headimg h1 {
            margin-bottom: 0;
        }
        #headimg h1 a{
            font:80px WoodenNickelBlackRegular, "Times New Roman", Times, serif;
            padding-left: 30px;
            text-transform:uppercase;
            text-decoration:none;
            width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
            height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
        }
        #desc {
            font:26px  Geneva, Verdana, sans-serif;
            padding-left: 30px;
        }
    </style><?php
}
add_custom_image_header('grisaille_header_style', 'grisaille_admin_header_style');

/**
* Change Excerpt length
**/
function grisaille_new_excerpt_length($length) {
    return 20;
}
add_filter('excerpt_length', 'grisaille_new_excerpt_length');

/**
* Change excerpt [...] to something else
**/

function grisaille_new_excerpt_more($more) {
    global $post;
    return ' ... <br /><a class="more-link" href="'. get_permalink($post->ID) . __('">keep reading</a>', 'grisaille');
}
add_filter('excerpt_more', 'grisaille_new_excerpt_more');

/**
* Thumbnail support
**/

add_theme_support( 'post-thumbnails' );  
set_post_thumbnail_size( 590, 275, true ); // 590 pixels wide by 275 pixels tall, hard crop mode
add_image_size( 'following-post-thumbnails', 250, 200, true ); // 250 pixels wide by 200 pixels tall, hard crop mode

// THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
add_filter( 'post_thumbnail_html', 'grisaille_post_image_html', 10, 3 );
function grisaille_post_image_html( $html, $post_id, $post_image_id ) {

    $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';

    return $html;
}

/**
* Google font API - adding Ubuntu font
**/
function grisaille_enqueue_scripts_styles() {
         wp_enqueue_style( 'Marvel', 'http://fonts.googleapis.com/css?family=Marvel');                                                 
}     
add_action('wp_enqueue_scripts', 'grisaille_enqueue_scripts_styles'); 

/**
* checks if the visitor is browsing either a page or a post and adds the 
* JavaScript required for threaded comments if they are
**/
function grisaille_queue_js(){
  if (!is_admin()){
    if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
      wp_enqueue_script( 'comment-reply' );
  }
}
add_action('get_header', 'grisaille_queue_js');

/**
* register_sidebar()
**/

add_action( 'widgets_init', 'grisaille_register_sidebars' );

function grisaille_register_sidebars() {

    /* Register the 'primary' sidebar. */
    register_sidebar(
        array(
            'id' => 'grisaillesidebar',
            'name' => __( 'Grisaille Sidebar', 'grisaille' ),
            'description' => __( 'Main right sidebar.', 'grisaille' ),
            'before_widget' => '<div class="sidebaritem">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>'
        )
    );

}   

/**
* Load the Theme Options Page for social media icons
*/
require_once ( get_template_directory() . '/inc/theme-options.php' );


/**
* Loads the theme's translated strings
*/

add_action('after_setup_theme', 'grisaille_language_theme_setup');
function grisaille_language_theme_setup(){
    load_theme_textdomain('grisaille', get_template_directory() . '/lang');
}   
?>

主体{}
#网站名称{
背景:url()0 0不重复;
最小高度:px;
利润率:20px0;
}
#网站名称H1A{
颜色:#;
最小高度:px;
}
#站点描述{
颜色:#;
}
#网站名称h1{
填充:0;
}
#网站名称H1A{
显示:块;
文本缩进:-9999px;
}
#站点描述{
显示:无;
文本缩进:-9999px;
}
@字体{
字体系列:“WoodenNickelBlackRegular”;
src:url('/type/woodenniwebfont.eot?')格式('eot'),
url('/type/woodenniwebfont.woff')格式('woff'),
url('/type/woodenniwebfont.ttf')格式('truetype'),
url('/type/woodenniwebfont.svg#webfontDYhQeecV')格式('svg');
字体大小:正常;
字体风格:普通;
}
#头模h1{
页边距底部:0;
}
#头模h1 a{
字体:80px WoodenNickelBlackRegular,“新罗马时代”,时代,衬线;
左侧填充:30px;
文本转换:大写;
文字装饰:无;
宽度:px;
高度:px;
}
#描述{
字体:26px日内瓦,Verdana,无衬线;
左侧填充:30px;
}

您应该删除此行,它用于定义自定义缩略图大小:

add_image_size( 'following-post-thumbnails', 250, 200, true ); // 250 pixels wide by 200 pixels tall, hard crop mode
然后在index.php中更改以下行(它告诉缩略图使用上面定义的自定义图像大小):

我不确定Wordpress的缩略图是如何工作的,但请尝试上传新图像,看看缩略图的大小是否正确。看起来后续文章的缩略图被永久裁剪,不会通过更改代码来调整大小


如果这不起作用,希望这里的文档能有所帮助:

grisaille\u post\u image\u html()
甚至没有使用它的第二个参数……您是否尝试过删除
添加图像大小('following post thumbnails',250200,true)?@Aaron yep,已删除该功能,且调整大小功能仍然存在。
add_image_size( 'following-post-thumbnails', 250, 200, true ); // 250 pixels wide by 200 pixels tall, hard crop mode
<?php the_post_thumbnail('following-post-thumbnails'); ?>
<?php the_post_thumbnail(); ?>
set_post_thumbnail_size( 590, 275, true );