2015-08-15 62 views
-1

我已經將我的網站從本地導入到實時服務器,並且此錯誤僅出現在我的4張圖像中,並且在本地服務器上完美運行。HTTP請求失敗! HTTP/1.1 404沒有找到

警告: 和getimagesize(http://localhost/theshavingsaloonNEW/wp-content/uploads/2015/08/step1.jpg) [function.getimagesize]:未能打開流:HTTP請求失敗! HTTP/1.1 404 Not Found in /nfs/c11/h03/mnt/206312/domains/theshavingsaloon.com/html/wp-content/plugins/wr-pagebuilder/shortcodes/image/image.php on line 223

這裏是圍繞線223 if語句,如果有幫助

if ($image_file) { 
    $image_id = WR_Pb_Helper_Functions::get_image_id($image_file); 
    $attachment = wp_prepare_attachment_for_js($image_id); 
    $image_file = (!empty($attachment['sizes'][$image_size]['url'])) ? $attachment['sizes'][$image_size]['url'] : $image_file; 
    $data = getimagesize($image_file); 
    $width = $data[0]; 
    $height = $data[1]; 
    $html_elemments .= "<img width='{$width}' height='{$height}' src='{$image_file}'{$alt_text}{$class_img} />"; 
    $script = ''; 
    $target = ''; 
} 

回答

0
http://localhost/theshavingsaloonNEW 

這是一個本地主機url而不是生產網址。請嘗試以下方法,以解決:在管理儀表板

  1. 更新WP地址的網址 - >設置 - >一般情況下,有兩個變化。

  2. 執行db的sqldump並使用文本編輯器將localhost替換爲您的域,然後重新上傳。

  3. 如果您有自定義模板或自己創建主題並使用文本編輯器查找http://localhost的任何實例,請下載當前主題文件夾/子主題。替換爲get_site_url()./restofurl

  4. 在將來使用遷移插件來簡化它時,它會爲你做db工作。

+0

謝謝你依靠我的查詢!我用我的域名替換了我的數據庫中的localhost,但是我無法在我的主題文件夾或我的子主題文件夾中找到本地主機的任何實例?這是正常的,因爲錯誤仍然出現,現在編輯主題的更多方面消失了? – Lisa

+0

警告:getimagesize(http://theshavingsaloon.com/theshavingsaloonNEW/wp-content/uploads/2015/08/step1.jpg)[function.getimagesize]:無法打開流:HTTP請求失敗! HTTP/1.1 404找不到/nfs/c11/h03/mnt/206312/domains/theshavingsaloon.com/html/wp-content/plugins/wr-pagebuilder/shortcodes/image/image.php在第223行 - 這是錯誤現在 – Lisa

+0

在你的主題中應該沒有localhost參考。您應該使用get_site_url()來獲取正確的主頁URL。正如你可以從你已經發布的網址看到的,現在wp認爲你的網址是http://theshavingsaloon.com/theshavingsaloonNEW,你有沒有在任何網址前加上shavingsaloonNEW?搜索您的主題也是如此。還要檢查所有已定義的常量。 – David

0

,我可以猜你已經離開硬編碼爲你的「localhost」的圖片網址。 您應該使用plugin_dir_url()方法自動生成網址。 請參閱this關於codex功能信息的鏈接。

P.S.另外,您可以使用wp_get_template_directory_uri() . 'your-path-relative-to-/wp-content/themes/'在主題模板文件中使用。

0

錯誤的圖像URL正通過getimagesize函數傳遞。它似乎是採取圖像的本地網址。

您應該檢查$image_file是否包含正確的圖像網址。

相關問題