2012-02-23 51 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()
我沒有嘗試它自己,希望它幫助。