在wordpress中将图像裁剪为一定大小

Tom*_*Tom 2 wordpress

我正在尝试裁剪图像.

我试过用

add_image_size( 'other', 105, 70, true );
 $imageString.= '<div><a href="' . $linkstring . '">' . get_the_post_thumbnail($post->ID, 'other;) . '</a></div>';
Run Code Online (Sandbox Code Playgroud)

但它似乎没有削减到那个确切的维度.

任何Ides?

nop*_*ies 9

通常,您将图像大小添加到functions.php文件中.

//post thumbnail support
add_action( 'after_setup_theme', 'theme_setup' );

function theme_setup() {
      if ( function_exists( 'add_theme_support' ) ) {
        add_image_size( 'other', 105, 70, true ); 
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,一旦到位,对于所有新的图像上传,wordpress将创建该大小的图像.

如果您想为已上传的图片创建这些图片大小,请查看http://wordpress.org/extend/plugins/regenerate-thumbnails/