Our free WordPress themes are downloaded over 2,500,000 times. Get them now!
Wordpress Thumbnails Generator

Uploaded images are not resizing and generating thumbnails on WordPress using Ubuntu, Debian or CentOS VPS

Today I ran into a problem when I was trying to setup a new WordPress based website hosted on a clean LEMP server using Ubuntu. The thing I noticed was that thumbnails and featured images where not properly resized, well they weren’t resized at all. Correct CSS styles were applied but image size remained uncropped. I did some research on WordPress.org and other WordPress related support forums but could find the answer.

Actually the first thing that came in my mind was that I made some mistakes in my theme pre as this was my own custom theme. I red every topic about

add_image_size

and

the_post_thumbnail

and couldn’t find a single mistake in my pre. And turned out that I didn’t suck at PHP and WordPress functionality but it turned out to be a bigger problem and it has something to do with my server configuration (Ubuntu in my case). Once I realized that it took a moment to realize what is missing – GD module for PHP5.

GD module for php5 is used to handling graphics directly from PHP scripts. It supports the PNG, JPEG, XPM formats as well as Freetype/ttf fonts. If you don’t have this PHP module installed it means that several WordPress features won’t work, such as  image resizer, image cropping, thumbnail and featured image generator and even oEmbed for Twitter, SoundCloud and other content won’t work. I learned this a hard way.

If you are facing the same issues with your WordPress installation you are in the right place because I will show you have to fix this. This will work only if you are running your own VPS/Dedicated server running Ubuntu and won’t help if you are on shared hosting account. However, you can ask them to install GD PHP5 module for you but most shared host already has it installed. If you are on shared web hosting it is highly likely that featured images and thumbnails are not generated because of some other reason.

Solution for Ubuntu and Debian:

To install GD PHP5 module on Ubuntu (any version after 12.04) and other Debian based systems you should run the following commands:

sudo apt-get install php5-gd
sudo service nginx restart

In case you are on Apache (LAMP) server then you can restart it like this

sudo service apache2 restart

Solution for CentOS

sudo yum install php-gd
sudo service httpd restart

These simple commands will install GD PHP5 module for your Ubuntu/Debian or CentOS which will enable WordPress functionalities such as thumbnail generator, featured image generator, image editor, oEmbed and probably some more that I didn’t notice.

Let me know if this is not the case in your situation and I will try to help.

Aigars

Frontend web developer and web designer specialized in free and premium WordPress theme development. Started to learn to code 2 years ago and now I am familiar with CSS/HTML/JavaScript (jQuery) and PHP. Obsessed with application performance, user experience and simplicity.

This Post Has 9 Comments
  1. You’re a lifesaver! I was about to go nuts debugging! I migrated servers from Apache to Nginx in Debian, and I couldn’t find any errors. As soon as I saw “GD” in your post it seemed so obvious!

    Tested and working solution!

  2. Fernando,

    I had a hard time figuring it out myself and then it hit me 🙂

    I was 100% sure that I installed it at first as this server was live for few months but didn’t notice that some functionality is missing. Sometimes the questions are complicated and the answers are simple.

  3. Thank you for this. This was driving me crazy!! No errors, no problems, just not working. This was a real pain of an issue but all is now solved

  4. I have already installed a new theme in WordPress for a personal project and WordPress couldn’t crop images when I uploaded them to a post. I had spent many hours to find the solution and your post solve it. Thank you Aigars!!! 😉

Leave a Reply

Your email address will not be published. Required fields are marked *