In one of my recent posts, I wanted to add a .GIF image but every time I tried to upload it an error like the one below appeared:
An HTTP error. Every time I try to upload the gif image the same error occurred.
The problem with this error is that it isn’t descriptive. It doesn’t tell you why the GIF couldn’t be uploaded or what is exactly wrong.
So, why does an HTTP error occurs while uploading JEPG, PNG or GIF images?
HTTP error occurs when something goes wrong and WordPress can’t upload the media file on your server. There are many reasons which might result in this error but unfortunately, there is no fit-for-all solution to this error.
I tried for 40 long minutes before finding the solution that actually worked.
In this article, I’ll show you how you can solve the HTTP error while uploading .GIF files.
There are a couple of methods that I want to show you. Try each of them until you find the one that works for your WordPress site.
1. Deactivate Image Optimization Plugins
Depending upon your settings an image optimization plugins may resize the GIF every time you upload it. Whether you upload it through WordPress browser media uploader or popup image uploader through the Gutenberg or TinyMCE editor.
Most of the image optimization plugins don’t have an exclusion rule for .GIF file type. That means they will compress the .GIF file every time you upload it. It may also happen that they resize it and in such cases, the GIF won’t load properly resulting in an HTTP error.
If you have any active image optimization plugin, deactivate them and retry to upload the GIF.
Make sure you delete the cache after disabling the plugin.
This should probably work as it did work for me. If it didn’t, move on to the next solution.
2. Disable Images SEO Plugin
These plugins also try to resize and compress images to further decrease the load time of your pages. So, it might happen that the image SEO plugin you are using is causing this error.
Disable any image SEO plugin and re-try uploading the .GIF file. Or if you don’t want to lose the alt tags, disable the image compression settings inside the plugin.
Below is a screenshot on how to do it for popular image SEO plugin: SEO image optimizer.
3. Increase Memory Limit
If you are on shared hosting, chances are your server is having low memory due to which WordPress is unable to upload the GIF file.
The quickest way to solve the HTTP error is to increase the WordPress memory limit. Copy the PHP code below and paste it in your wp.config.php file to increase the memory limit to 256 MB.
define( 'WP_MEMORY_LIMIT', '256M' );
Try re-uploading the GIF file. This should probably fix the problem.
4. Ask Your Web Host
If the above three solutions didn’t work in your case, there might some error from your web hosting. Reach out to your hosting support and ask them to check your server. Tell them to restart if you’re on Nginx servers.
This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.
If your web host fails to solve your problem, it might be a sign to migrate to a better host.
By now you should be able to upload a GIF and any other image on your WordPress blog without any issues. Sometimes the HTTP error is temporary and waiting for a couple of minutes might be the best you can do.
Server updates etc. might result in an HTTP error and in such cases, you can only wait and re-try uploading.
5. Remove Special Characters From Image File Name
If your image name contains any kind of special characters such as an inverted comma (“) or a semicolon (;) etc., then you won’t be able to upload it on WordPress through media uploader.
You’ll have to remove the special characters from the GIF file name and re-upload it.
After you’ve completed uploading the GIF image, you might get into another error where WordPress doesn’t play the GIF animation.
WordPress won’t play the compressed or resized GIF animation when you add it into your post. When you upload a GIF file, WordPress automatically saves its first frame as the original image and hence you won’t see the GIF play when you add it into your blog post.
The quick solution to this particular problem is uploading the GIF through WordPress popup media uploader:
- Open the WordPress editor and start writing or editing a post
- Click on add media button above the editor
- Upload the GIF here and click on the full-size option before adding it to the post
This would restore the animation of your GIF image.
I hope now you’re able to upload GIFs on your WordPress blog. Make sure you delete the cache each time you try to preview the animation.
Let others know which solution worked for you in the comments section below.