WordPress migrations can be performed flawlessly if a few tips are kept in mind.
A common issue faced after a manual WordPress migration is missing images. Images will be present in the backend, however, it won’t show up in the WordPress dashboard or on the website.
As a part of our Server Management Services, we perform WordPress migrations almost every day for web hosts, data centers, eCommerce companies, and other businesses. And this image missing error comes up occasionally during these migrations.
Today, let us discuss the possible causes of this issue and how we fix it at our end.
Why do images disappear from WordPress?
There are several reasons for images to disappear from WordPress. The most common ones are:
- Incorrect home and site URL.
- Incorrect image URLs.
- Incorrect references in image URLs.
- Incorrect permalink setup.
- Plugin Conflicts.
- Problem with image name
- Wrong file permission or ownership.
Incorrect home and site URL
The most common reason for missing images after a WordPress migration is incorrect Home and site URL settings provided for the website.
If there is a change in the domain name during migration, the home and site URL of WordPress website needs to be updated to the new one.
Incorrect home and site URLs can cause the images in the home page to disappear, the website to redirect to the old one or even the dashboard to not load.
If the WordPress dashboard is accessible, the home and site URL can be fixed easily from the General settings page in Settings.
If the dashboard is not accessible, it should be corrected by adding WP_SITEURL and WP_HOME URLs in wp-config.php with the current path of WordPress. This is added in the format below:
Incorrect image URLs
Images are referenced as URLs in the WordPress database. When there is a change in the domain name during migration, the image URLs also need to be updated to that of the new domain name.
Most of the WordPress migration plugins perform this step automatically. But if it was a manual migration, the image URLs need to be updated separately. The easiest way here is to use a search and replace plugin.
We can also change the image URLs manually from the wp_posts table in the database. If it is WHM server, then this can be directly done from SQL option in the PHPMyAdmin for the corresponding database using the commands below:
UPDATE wp_posts SET post_content=(REPLACE (post_content, ‘<old url>’,'<new url>’));
Incorrect references in image URLs
Images can disappear at the destination of the website migration if SSL is installed at the destination host and the images are hard-coded over http://. Some of the SSL plugins can also cause this issue.
It can be fixed easily by changing the http:// references to https://. The search and replace plugin or the PHPMyAdmin method mentioned above can be used to fix this.
Incorrect permalink setup
If the permalink setup at the source and destination of the migration is different, it can cause the images to disappear.
Permalink setup can be easily corrected from the Permalinks section in the Settings area of the WordPress dashboard.
Some of the plugins that worked really well in the source server may fail to show the same performance in the new environment due to minor changes in the working environment. This at times causes images to disappear from the website.
Some of the plugin’s settings need to be adjusted to fix the issue. PHP or other server-wide settings may also need to be adjusted to make the image visible on the website again.
We at Bobcares systematically analyzes the log files to locate the exact plugin and the settings that throw the error.
Problem with image name
Based on the PHP version used by the website, some of the characters, especially special characters may not be supported by the server. Thus if the file name for the image includes any such character, it may fail to deliver on the website.
The simplest fix for at this stage is to try changing the file name to another one that does not contain any such character.
Wrong file permission or ownership
A directory would ideally need 755 permission, and files will need 644 permission to be retrievable by WordPress. If there is any change in this permission, WordPress may fail to deliver images on the website.
Also, it is important to change the ownership of the files to match that of the server settings, after extracting the backup file. Changing these settings to the recommended values will immediately fix the issue with the images.
To sum up, images can disappear from the WordPress website during migration due to many reasons. It is important to identify the exact reason to bring the images back. Today, we discussed common reasons that can cause the images to disappear and how our Support Engineers bring back images in each case.