WordPress更改特色图像的图像宽度和高度

时间:2012-10-12 11:20:45

标签: css wordpress image-processing wordpress-theming

我对Wordpress很新。我想知道如何为image width and height size定义featured image?我希望我的所有图片都应该是100 X 100 px。那怎么办呢?欢迎任何帮助和建议。

5 个答案:

答案 0 :(得分:1)

您可以尝试this之类的内容吗?

答案 1 :(得分:1)

使用此代码并调整特色图片尺寸

<?php query_posts('cat=ID'.'&showposts=NO. OF POST') ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<!-- Thumbnail part start-->
<div style="100px"; width="100px";><?php the_post_thumbnail(); ?></div>
<!-- Thumbnail part End-->
<p><?php echo substr(get_the_excerpt(), 0,65).' [...]'; ?></p>
<a href="<?php the_permalink(); ?>">Read More...</a>


<?php endwhile; ?>
<?php wp_reset_query(); ?>
 <?php endif;?>

答案 2 :(得分:1)

设置新的帖子缩略图大小后,您必须重建缩略图,因为Wordpress已经构建了缩略图。

为此您可以使用例如this plugin,但请记住,它因安全问题而闻名。我的建议是安装它,重新生成缩略图,使它们具有你设置的新大小,然后卸载它。

希望这会有所帮助。欢呼声。

答案 3 :(得分:0)

将此行放在add_image_size('thumb',100,100,TRUE); functions.php

并在任意位置调用the_post_thumbnail('thumb');

有关详细信息,请检查该链接:http://codex.wordpress.org/Function_Reference/add_image_size

答案 4 :(得分:0)

在function.php文件中使用类似的东西

<?php add_image_size( $name, $width, $height, $crop ); ?>

参数将如何

$name (string) (required) The new image size name.

$width (int) (optional) The post thumbnail width in pixels.

$height (int) (optional) The post thumbnail height in pixels.

$crop (boolean) (optional) Crop the image or not. False - Soft proportional crop mode ; True - Hard crop mode.

有关详细信息,请查看wordpress codex文档。