Wordpress 自定义特色图片大小? [英] Wordpress Custom Featured image size?

查看:64
本文介绍了Wordpress 自定义特色图片大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了我在这里找到的每个解决方案,但仍然无法让我的特色"图像显示它的大小合适,某些东西不断地迫使它使用 wp 默认的 150x110 像素.

I have gone through each of the solutions I've found on here, and still cannot get my 'featured' image to show it's proper size, something continually is forcing it to the wp default 150x110 px.

我进入了 wp/settings/media 并更改了缩略图大小...没有变化我进入了画廊/特色图片并关闭了除原始尺寸外的所有其他尺寸......没有变化我已经进入我的functions.php文件并更改了据称被调用的大小..

I have gone into wp/settings/media and changed the thumbnail size... no change I have gone into the gallery/ featured image and turned off all other sizes except for original... no change I have gone into my functions.php file and changed the size that is supposedly being called..

if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'homepage-thumb' );
    set_post_thumbnail_size( 420, 110 ); // default Post Thumbnail dimensions   
}

if ( function_exists( 'add_image_size' ) ) { 
add_image_size( 'category-thumb', 420, 9999 ); //300 pixels wide (and unlimited  height)
add_image_size( 'homepage-thumb',420, 110, true ); //(cropped)
}

在我的索引文件中,我有...

In my index file I have ...

<?php if(has_post_thumbnail()) {echo '<a href="'.get_permalink().'">';echo get_the_post_thumbnail($post->ID, array(420,110) );echo '</a>';} ?>

还是什么都没有..

当我检查 firebug 中的元素时,我看到:

When I inspect the element in firebug I see this:

<img class="attachment-420x110 wp-post-image" width="150" height="110" title="t-test2" alt="t-test2" src="http://pixelneer.com/wp-content/uploads/2012/01/t-test2-150x110.png">

所以它仍然从其他地方获取默认缩略图大小,我不知所措.

SO it is still getting the defualt thunbnail size from somewhere else, and I am at a loss.

我使用的是 starkers,网址是 pixelneer

I am using starkers, and the URL is pixelneer

推荐答案

调用缩略图时,请使用之前定义的 image_size 名称.例如,而不是:

When you call up the thumbnail, use the image_size name that you defined earlier. So for example instead of:

get_the_post_thumbnail($post->ID, array(420,110) );

使用:

get_the_post_thumbnail($post->ID, 'home-page-thumb' );

这篇关于Wordpress 自定义特色图片大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆