KNOWNHOST WIKI

User Tools

Site Tools


resources:how-to-fix-broken-image-links-in-wordpress

How Broken Image Links Happen in WordPress and How to Fix Them

Maintenance is as big a priority as creating new post content on WordPress sites, particularly when it comes to broken links - images and videos especially. Having a broken link pointing to an external site is bad because it's a poor user experience. But having a broken link pointing to media content on your own site is bad because it reflects poorly on you, not someone else!


There are several scenarios that commonly play out, each of which results in images disappearing from pages with broken links replacing good, working ones.


Scenario #1 - URL Architecture Changes

Depending on how you've added media to a site, there are some cases of changing category structures and naming conventions which can result in images no longer working. This is particularly true if you've uploaded images into certain folders and then used relative paths to point to them.

Image linking methods can include:

The fix is to either undo the change made or browse to the page/post with broken links and edit the image link within the page/post, then click update.


Scenario #2 - a Page or Post is Moved

Along the lines of Scenario #1, there are times when you've decided to relocate a post or page in WordPress and somehow the system loses track of where they reside.

Newer versions of WordPress are generally very good at handling this situation, but it's traditionally been a very common happening.

The fix is to either undo the change made or browse to the page/post with broken links and edit the image link within the page/post, then click update.


Scenario #3 - WordPress Settings Changes

The desire to tinker is a powerful one, which is what drives people to edit the WordPress Admin panel Settings → Media.

There can be a file path dialog which appears allowing users to specify a different upload file path. If you've got a non-default value in the box, then change it to a default value and save it, many of the blog images will break and the box allowing you to change the value can disappear - a very cool feature of WordPress to protect the default settings, once they're made default.

You can force WordPress to make the settings box reappear and let you set it back to some other value by following these steps:

  1. Login to cPanel
  2. Run phpMyAdmin
  3. Select your WordPress database
  4. Execute the following query:
    UPDATE wp_options SET option_value = 'wp-content/foo' WHERE option_name = 'upload_path'
  5. Go back into WordPress Admin, Settings → Media and change the value of the upload path, returning it to what it had been before the tinkering session.

If you're unsure of this, contact the KnownHost technical support team by opening a helpdesk trouble ticket.


Scenario #4 - WordPress Config Changes in wp-config.php

Similar to #3 above, it can be the case that modifications to the wp-config.php file have happened and they've caused a wholesale breakage of images in WordPress.

By changing the uploads folder to point elsewhere, WordPress is now looking in the wrong places for the files it needs to put media in posts and pages.

Fixing this problem means you need to:

  1. Login to your control panel
  2. Run File Manager / File Editor
  3. Navigate to the root folder where WordPress wp-config.php is located
  4. Edit the file
  5. Look for define('UPLOADS', 'wp-content/some-folder-location');
  6. Change that part to the right of the comma with the correct folder where your uploaded images are found


Good News

In most cases fixing one or two broken images in WordPress can be done by simply opening WordPress Admin Pages or Posts, finding the page or post with the broken media, selecting it and choosing alternative media from the library or uploading.

Other, more technical, solutions are only needed when things have gone wrong on a bigger scale.

Don't forget, there's always KnownHost support available to help you when things go wrong if you find yourself in hot water. Open a support ticket, explain the situation and get a helping hand. That's part of what managed hosting is all about!

resources/how-to-fix-broken-image-links-in-wordpress.txt · Last modified: 2020/09/29 06:38 by Karson N.