Lisa Lisa - 5 months ago 18
PHP Question

HTTP request failed! HTTP/1.1 404 Not Found

I have imported my site from a local to a live server and this error has come up for only 4 of my images and it worked perfect on the local server.


Warning:
getimagesize(http://localhost/theshavingsaloonNEW/wp-content/uploads/2015/08/step1.jpg)
[function.getimagesize]: failed to open stream: HTTP request failed!
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


Here is the if statement around line 223 if it helps

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 = '';
}

Answer
http://localhost/theshavingsaloonNEW

this is a localhost url rather than a production one. Try these options in order to solve:

  1. update wp address urls in the admin dashboard -> settings -> general, there are two to change.

  2. Perform a sqldump of the db and use a text editor to replace localhost with your domain and then re-upload.

  3. Download the current theme folder / child theme if you have custom templates or made the theme yourself and use a text editor to find any instances of http://localhost. Replace with get_site_url()./restofurl

  4. In future use a migrate plugin to make this easy, it will do the db work for you.

Comments