Support » Fixing WordPress » Broken Images after moving from Shared Hosting to VPS

  • Resolved Pengo26


    Hello, so I have searched endlessly for solutions to this problem. After trying to use the numerous solutions for my problem found on here and throughout the internet and finding out that they don’t work and actually broke my website more and more I had to reinstall the entire server. Alas I am at wit’s end.

    I have Imagick installed, the images are being uploaded correctly to the correct folder, they are being generated into different sizes by Imagick. I have a VPS running Cent OS 6, with latest Apache, latest PHP.
    Mod Rewrites are on. Upload path is defaulted.

    I have a custom theme called Pricerr. You can visit my website here:
    If you go to the job called Shared Hosting for $7, you can see that the image does not work and appears broken and if you click on it it says request failed. All of the images before the migration appear to work. Anything new I upload appears broken like the example above.

    I’ve contacted my developer and they say it must be a hosting problem. Which would be fine except that I am the host of the VPS.

    Thank you for the help! This has been frustrating me for 72 hours!

Viewing 9 replies - 1 through 9 (of 9 total)
  • When I look at that item on your site it appears that the URL to the images is incorrect, and I get a 404 in Firebug that instead of listing some strange non-existant URL, lists “is-wp-error.” The image tags themselves also show that “is-wp-error” for the src attribute.

    I also get a "NetworkError: 403 Forbidden -" which makes me think you may have a user/permissions error in there somewhere. There are a couple of other errors showing up in Firebug, but that’s the one I would be most suspicious of.

    All this has me wondering if the problem may be the permissions granted and/or user assigned to the new files you upload now that you’re on the VPS, which would explain why the old ones work and the new ones don’t.

    To confirm if this is the issue, take a look at the image files for that item on your server using an FTP program (like Filezilla, for example) that shows you not only the permissions but also the user/group assigned to that file. Compare them to those for a file that you know works, and see if they’re different. If they are, you have found the problem. The solution will be easier after you identify the problem.

    The other thing I’d do is check for the error_log file in your public_html folder to see if it has anything to contribute.

    All the permissions for the folders are 755 and 644 for the actual images in wp-content. Both Owner/Group are by 501 and 512, which means the owner/group for both working and non-working images are the same.

    The error logs only says: PHP Warning: getimagesize(/home/dormgigs/public_html/wp-content/uploads/2014/03/cms-265127_1280.jpg): failed to open stream: No such file or directory in /home/dormgigs/public_html/wp-content/themes/PricerrTheme/functions.php

    The image exists in multiple sizes and original size

    What happens if you create a test.php page with the following code in it, upload it to your site, and browse to it?

      $file = '/home/dormgigs/public_html/wp-content/uploads/2014/03/cms-265127_1280.jpg';
      if (is_file($file)) {
        $imginfo = getimagesize($file);
        foreach ($imginfo as $key=>$val) {
          echo $key . ' = ' . $val . '<br />';
      } else {
        echo 'The file was not found.';

    If that works, then I’d look at the code in /home/dormgigs/public_html/wp-content/themes/PricerrTheme/functions.php, but I can’t explain why that code would be affected by your switch to a VPS unless there’s something hard-coded in it that doesn’t agree with the new server.

    Yeah it works:
    0 = 1280
    1 = 853
    2 = 2
    3 = width=”1280″ height=”853″
    bits = 8
    channels = 3
    mime = image/jpeg

    But yeah I dont understand why function.php would be affected by a vps switch. Here is the code regarding that particular part of function.php

    function PricerrTheme_generate_thumb($img_url, $width, $height, $cut = true)
    	require_once(ABSPATH . '/wp-admin/includes/image.php');
    	$uploads = wp_upload_dir();
    	$basedir = $uploads['basedir'].'/';
    	$exp = explode('/',$img_url);
    	$nr = count($exp);
    	$pic = $exp[$nr-1];
    	$year = $exp[$nr-3];
    	$month = $exp[$nr-2];
    	if($uploads['basedir'] == $uploads['path'])
    		$img_url = $basedir.'/'.$pic;
    		$ba = $basedir.'/';
    		$iii = $uploads['url'];
    		$img_url = $basedir.$year.'/'.$month.'/'.$pic;
    		$ba = $basedir.$year.'/'.$month.'/';
    		$iii = $uploads['baseurl']."/".$year."/".$month;
    	list($width1, $height1, $type1, $attr1) = getimagesize($img_url);
    	//return $height;
    	$a = false;
    	if($width == -1)
    		$a = true;
    	if($width > $width1) $width = $width1-1;
    	if($height > $height1) $height = $height1-1;
    	if($a == true)
    		$prop = $width1 / $height1;
    		$width = round($prop * $height);
    		$width = $width-1;
    	$height = $height-1;
    	$xxo = "-".$width."x".$height;
    	$exp = explode(".", $pic);
    	$new_name = $exp[0].$xxo.".".$exp[1];
    	$tgh = str_replace("//","/",$ba.$new_name);
    	if(file_exists($tgh)) return $iii."/".$new_name;	
    	$thumb = image_resize($img_url,$width,$height,$cut);
    	if(is_wp_error($thumb)) return "is-wp-error";
    	$exp = explode($basedir, $thumb);
        return $uploads['baseurl']."/".$exp[1];

    That tells us that the getimagesize() method works in PHP, and that there are apparently no file permission or user/group issues, I think.

    That makes it look like the issue is within WordPress, the theme, or perhaps a conflict between plugins or a plugin and the theme.

    I played around loading the pages that do and do not work, and I see that there are a variety of errors, some hard to see because the way the content loads, but they seem to occur on both the pages where the images load and on those they don’t, so I don’t think that’s the cause of the problem, but I’m not sure.

    I keep coming back to why that “is-wp-error” is in the src attribute for the missing image.

    Have you tried disabling all the plugins you’re using and just testing with the theme activated alone? If that fixes it, you can activate one plugin at a time and perhaps identify the culprit to make it easier to troubleshoot.

    Yeah I’ve tried that already, images still appear as broken.
    The plugins are the same as they were before migration too.
    About the “is-wp-error,” it’s in the code.

    Yeah, I am really stumped.
    Thanks so much for helping out!

    I am stumped too. I can’t think of anything that might be on the VPS that would cause this since the test file showed you have no permissions problems or issues with the file itself or PHP.

    The only other thing I can think of is to compare the PHP configuration of your shared host to the one on the VPS, including comparing the two php.ini files.

    Sorry I couldn’t help you solve it.

    If you find the solution, please post back here. I am very curious as to the cause.

    Okay I think I fixed it!!!!!!!!!!!!!
    So I decided to quit on it and install OS-Classifieds instead. And in that install, OS-Classifieds says that I was missing Zip Module, mCrypt module, GD Library, mbString module, and MySQLi. So I decided to re-compile Apache with all those modules in it and it works!

    I don’t think the GD Library did much because I attempted that before, but I think mbstring, Zip module and MySQLi had something to do with it.

    Thanks so much for your help anyways!

    Fantastic! I’m glad you got it fixed.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Broken Images after moving from Shared Hosting to VPS’ is closed to new replies.