Solution To WordPress getimagesize() Error

If you’ve for whatever reason noticed that your WordPress website is generating errors similar to the following then I may have a solution for you.

Warning: getimagesize(/home/.some-dir/example.com/folder/httpd.www/wp-content/uploads/some-image.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/.some-dir/example.com/folder/httpd.www/wp-content/blah/blah/blah.php on line 123

I noticed that some pages that generated image information were printing errors out on my pages with private server file structures included. Generally you don’t want to see this printed out to the public. ๐Ÿ˜‰

I’m not guaranteeing a fix for you, but rather what worked for me.

If you are getting an error link the one that I’ve listed above, more specifically the “failed to open stream: No such file or directory,” then you may be about to fix it in only a few minor steps.

Things you will need:

  • FTP (I use FileZilla)
  • phpMyAdmin
  • Ability to add a new plugin to your site
  • Patience

Procedure

Single quotes must be the normal ascii quotes. Chances are, if you copy and paste from my blog, they will be the wrong type so double check that as it could give you problems. ๐Ÿ˜‰

  1. First and foremost, make sure to backup your entire database to a safe place. I’m not liable in the case that you don’t backup your database and this procedure borks your blog (or any other case for that matter). ๐Ÿ˜‰
  2. Create a new file named “abstest.php” and upload it to your blog’s root directory after entering the following code into it:
    <?php define('ABSPATH', dirname(__FILE__).'/'); echo ABSPATH; ?>
  3. Open a new browser tab and navigate to “http://www.your-website.com/abstest.php“. You should find a short page with the printout of your servers absolute path.
  4. Check that the path provided by this test file matches the base path printed out by the getimagesize() error exactly. In my case, my server had changed slightly so the differences were similar to the following:
    /home/.some-dir/example.com/folder/httpd.www/
    /home/example.com/folder/httpd.www/
  5. If you find a mismatch, then you’ve found your problem and the rest is simple. If not, then my tips will most likely not solve your particular WordPress error(s).
  6. If you’ve found a mismatch, then continue: Open a new browser tab and navigate to your phpMyAdmin interface. Select your WordPress database, then click Search. I searched all tables for a match of the path that was different, in my case it was “.some-dir/“.
  7. If there are matches found then you need to click the SQL tab at the top (preferably in a new tab) and paste the following (making sure to edit it to match the table and fields you need) and run it to find and replace that changed part of the path.
    update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, โ€˜find this stringโ€™, โ€˜replace found string with this stringโ€™);
    For more information on SQL find and replace, either search Google or read this.
  8. After replacing all of the affected tables and strings, your images should be properly address. You’re not done yet though.
  9. Open WordPress Plugins and add/install a plugin named “Regenerate Thumbnails“. After installing it, make sure to activate it. ๐Ÿ˜‰
  10. In your Admin panel, find the Tools menu and expand it. You should see a menu item labeled “Regen. Thumbnails”…click it. This will open a page with a start button. Clicking this button will begin the process of correcting your thumbnail dimensions as well as other metadata. It will take some time depending on the number of thumbnails you have accumulated.
  11. After the progress bar reaches 100% it will notify you that it is complete. You’re all done! You may need to clear your cache to refresh any pages that still generate the previous error message.

If you had any problems with the above mentioned procedure, I would suggest restoring your database using your backup copy and either trying again, paying someone to do it for you or just forgetting about it. ๐Ÿ˜‰

If it works then great! If not then sorry you’ve wasted your time. It worked for me, so maybe it will work for you as well. ๐Ÿ˜€

Gmail: Server Error 502

Well, Gmail has been down for a while today. I’m hoping it will come back up pretty soon, but if you’re also getting an Error 502 message then you may be waiting for a while as well.

I did a little research (google is your friend..unless it’s Gmail with a 502 message, haha) and it looks like it happens fairly often to people. One person reported not being able to login for up to 4 days!

I also read that sometimes logging in with a different browser will temporarily fix the problem, but it didn’t work for me with Opera, Firefox or Internet Explorer.

Hopefully everyone else is having better luck.

UPDATE: It appears that the Gmail outages were indeed as wide spread as I had assumed. Webmonkey.com even covered the issue in their blog (hours after I released a post about it, haha) and got the following statement from Google on the issue:

Since about 2 p.m. Pacific Time today, many Gmail users have been unable to access their email. We are very sorry for this interruption in service. The issue is being caused by a temporary outage in the contacts system used by Gmail which is preventing Gmail from loading properly. We are starting to roll out a fix now and hope to have the problem resolved as quickly as possible. Even though you may not be able to get to your inbox right now, your mail is safe, including new incoming messages.

We will post an update in the Gmail Help Center ( http://mail.google.com/support/ ) when more information is available.

Gmail seems to be back in order now and apparently came back online around 8pm EST. Hopefully no one is still affected by the outages.