Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#8838 closed enhancement (wontfix)

relative (image) links not showing properly in edit post/page

Reported by: ollivdl Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.7
Component: Administration Keywords: relative links - subroot WP
Focuses: Cc:


Since there is an article on relative image links, I guess I might expect it 'should' be supported in editing pages/posts.

I use them a lot, since the domain name of my server could be two different ones, also it is way much faster to compose in html/image adding window.

So what I'm talking about?
i use <a href="images/large/picture_name.jpg"><img src="images/small/picture_name.jpg" /></a>

Also I would like to mention that the info on the WP.org is not mentioning the difference between e.g.
/images/image_name.jpg --> resulting in webroot/images/image_name.jpg
images/image_name.jpg --> resulting in WordPress root/images/image_name.jpg

The thing is I have my photo gallery in a own directory '/photo' of my webroot, running an own Wordpress on the side of the one in the root folder. having the index in /photo/index.php

Using the WP in the subdirectory, I link to images using href"images/large/image_name.jpg". This results in a url towards http://mydomain.com/photo/images/large/image_name.jpg

Now editing the posts with images linked starting with 'images/image_name.jpg' don't show up in the diting, but the output is perfect. This results in errors of Apache telling me

File does not exist: /Library/WebServer/Documents/photo/wp-admin/images/small

It seems like the editor links it to wp-admin as root.
Can this be solved? Or do I need to link everything (100 + imgs) like this:


I would have to type more in the futre then...

Change History (4)

#1 @DD32
7 years ago

  • Component changed from Optimization to Administration
  • Milestone changed from 2.8 to 2.9
  • Type changed from defect (bug) to feature request

I have a feeling this will be a wontfix.

relative url's do not play nice with WordPress and permalinks in the first place, (which you might not be using), and while it would only be a 1 line change, to me, it really seems like its setting someone up for a disaster down the line related to url's changing, or pretty permalinks being enabled

for reference, adding

<base href="<?php bloginfo('url'); ?>" />

to admin-header.php would be the way to enable that, but the problem is that it'd affect a lot of WP links in core and plugin(mainly menu's linking to the wrong location, and links on pages refering to other admin pages linking to the wrong location, etc.), and be absolutely useless to the majority of people(because of permalink structures including slashes)

You're better off using the builtin media library, or using the "Insert from URL" function if you dont want to type that much..

I dont see why !wordpress.org should tell you the difference between absolute and relative links though, if you're in advanced mode and typing the html yourself, you should understand what you put in the href/src tags, WordPress.org is not a site to teach you HTML (and WordPess asks for full absolute urls everywhere)

#2 @ollivdl
7 years ago

Well, thanks anyway for checking it out, and pointing how useless it seems to be.

As WordPress docs explain what a relative link is, it seems to me it it supposed to be used. If people seem also to get explanations on how to move their wordpress files into a subdirectory of the webroot, then it can be understood that one would like to point out some suggestion as to explain different relative links imho.

What makes sense to one doesn't always make sense to the other. Even blogging at all doesn't seem to be something to bother about most of the people I know...

I will point out:

if you would have two domain names, one linking to a wordpress fatures site, and the other to your personal blog, and maybe another one... All pointing at the same IP adress, but all residing in different subfolders...

Linking in the blog towards an image in another subfolder of your pictures site, to invite people there, would be nice to do like this:

<img src= "/photo/image.jpg" />
instead of having to type
<img src="http://myurlcouldbemediumlong.com/photo/image.jpg">

Well whatever, Using the library is no go here, none of the uploading ways (html/flash) want to crop my images. I know if cropping works, the images loose color depth and such...

I use watermarks and crop them externally to keep colours the way they should be. They are uploaded at once into a folder images with a subfolder 'small' for thumnails and logically 'large' for the linked images. They all carry the same name and an index number. couldn't be more easy.

I edit without seeing the images in the editor now, can jollygood edit all I want inside the editor (size, caption, title, name it!)
And the output is perfect on the site.

#3 @ollivdl
7 years ago

  • Severity changed from normal to minor
  • Type changed from feature request to enhancement


As far as I can conclude:
links to images should start with '/' to have the image always showing. In the website as well as in wp's admin.

image links should be set with the webroot in mind (see below)

starting without '/ - the relative link (the start of the confusion)

WordPress outputs the link into the website using its own rootfolder as the root for the link.

! This doesn't happen with the admin menu, hence the topic
neither if having set the permalinks, as I just find out.

e.g. images/image.jpg results in (whatever the root is of wordpress)/images/image.jpg also if wordpress resides in a own subfolder of the webroot

starting a relative link with '/'

Is resolved as a link starting from apache's webroot, in every case wheter or not WordPress resides in a subfolder of the webservers root

so having the root of WordPress in a subfolder of Apache's root, like in my case /photo, relative links should include this /photo in every relative link made

if files are in the rootfolder of WordPress.
WordPress in /photo
files in /photo/images

links to files should be written as /photo/images/image.jpg

quite boring, but it is yet a topic...
Sorry for wasting time =)

#4 @DD32
7 years ago

  • Milestone 2.9 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Resolving as wontfix. Relative links simply cannot be reliably worked around in both the admin and the front-page due to the varying folder levels which web browsers see.

Note: See TracTickets for help on using tickets.