How I can I get WordPress to stop making link-image URLs relative?

I'm trying to add logos to the blog-roll widget, but WordPress makes the URLs of the images relative to the current blog.

For example, if the site is example.com/blogs, the images in the blog-roll widget at the main blog work correctly, but the ones at example.com/blogs/foobar are broken because instead of using something like /common/bloglogos/main.png (or even https://example.com/common/blog/logos/main.png), it uses https://example.com/blogs/foobar/common/bloglogos/main.png.

I've tried various combinations of URLs and formats, but it always makes the images' URLs relative to the current blog which is annoying because it would require uploading the images for all of the blogs to each of them instead of having them all in a central location which can be updated as necessary with just one change.

The URLs of the links themselves are fine, it's just the URLs of the images of the links that are the problem.

To be clear, I'm talking about images associated with WordPress links. In the case below, instead of the WP links using the image at /whatever/something.png, it will append the URL to the sub-blog, resulting in the invalid URL https://example.com/blogs/foobar/whatever/something.png. In fact, if I put http://somesite.com/path/pic.jpg in the field, it will use https://example.com/blogs/foobar/http://somesite.com/path/pic.jpg. 🤦

screenshot of WordPress link image field

  • I've not encountered this problem in the same situation, are these images that are a part of the theme, or images that are in your post content? Do you have a relative URLs plugin installed? – Tom J Nowell Oct 20 at 0:01
  • They're just any old images; it doesn't matter what I use, whatever I put in the URL field gets appended to the each sub-blog's URL. No, I don't have that plugin installed. I tried doing a search but everything comes up with people trying to get relative URLs instead of absolute, and I'm stuck with the opposite. 🤦 – Synetech Oct 21 at 1:08
  • So these are images in your post content? Be as specific as you can to avoid confusion/ambiguity. Is this happening to newly uploaded images? Has the URL of your site been set properly in the settings area? – Tom J Nowell Oct 21 at 11:08
  • I added a screenshot to clarify what I'm talking about. – Synetech Oct 21 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.