2012-02-23 63 views
1

我一直在这个问题上很难。 我在Ubuntu服务器上运行Wordpress 3.3.1 64位WordPress的print_thumbnail不给正确的网址

因此,我可以上传图片并使用提供的网址查看图片。 但是,当我将其设置为功能图像时,看起来功能 print_thumbnail没有给我正确的地址。 它在/ var/www /之前添加/ my/wp-content/uploads/etc ... 因此绝对路径名在我的机器上借助一些符号链接是正确的。

我试着改变文件上的css来删除/ var/www /并验证这确实找到了我的图像并且工作。我已经看到很多帖子告诉我改变chmod 777并回到755,如wp print_thumbnail function is not workinghttps://stackoverflow.com/questions/9003277/wp-print-thumbnail-function-not-working-correctly我不知道这是如何解决这个问题,因为这似乎是一个路径问题。是否有某种基于权限的重定向?无论如何,它没有工作。

有没有人有任何想法?

下面是一个例子张贴 http://mobile.cs.fsu.edu/google-chrome-app-on-android-market/

回答

0

你可以尝试,而不是print_thumbnail这一点。

<?php 
if (has_post_thumbnail()) { 
    the_post_thumbnail(); // Outputs <img/> object with src="thumbnail-href" 
} 

同样,这也将工作:

<?php 
if (has_post_thumbnail()) { 
    echo(get_the_post_thumbnail(get_the_ID())); 
} 

如果你已经在你的functions.php设置多种功能的图像尺寸....

<?php 
add_theme_support('post-thumbnails'); 
set_post_thumbnail_size(120, 120); 
add_image_size('subfeature', 940, 300); 

你可以引用(其中subfeature是大小的名称):

<?php 
if (has_post_thumbnail()) { 
    echo(get_the_post_thumbnail(get_the_ID(), 'subfeature')); 
} 
0

在我发现的功能,它使用get_bloginfo功能打印出来的样式表目录

$output = '<img src="'.get_bloginfo('stylesheet_directory').'/timthumb.php?src='.$thumbnail.'&amp;h='. $height .'&amp;w='. $width .'&amp;zc=1"'; 

wordpress codex of get_bloginfo,它说:

“stylesheet_directory” - 返回的样式表目录网址 活跃主题。 (在早期的WordPress版本中是本地路径。) 请考虑使用get_stylesheet_directory_uri()代替。

更改get_bloginfo( 'stylesheet_directory')到get_stylesheet_directory_uri()
我没有尝试它自己,希望它帮助。