We at Colorlib know a thing or two about creating unique and successful WordPress themes,…

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.
Already did the same but still images are not showing
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!
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.
Thank very much ! I’ve got this problem…
Thank you! It was driving me mad that I couldn’t crop the pictures!
Thanks a lot!
Thanks It works perfectly!
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
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!!! 😉
Thanks, your tip really helps!
I still can’t get it to work 🙁 php info shows gd as enabled and working in core output but the thumbnails are not being generated. I am running wordpress 4.6 on centos 7 with php5.4 in aws instance. Tried changing themes, disabling plugins etc but nothing works
Thank you! It was driving me mad that I couldn’t crop the pictures!
Thanks a lot!