Make WordPress Core

Opened 10 years ago

Last modified 7 months ago

#30922 new defect (bug)

Link Manager: Doesn't support relative URLs for "Image Address"

Reported by: hartwork's profile hartwork Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: General Keywords:
Focuses: Cc:

Description

For links, the "Edit Link" page allows be to put in any of

  • http://blog.hartwork.org/__images/gentoo3-150x30.png
  • https://blog.hartwork.org/__images/gentoo3-150x30.png
  • /__images/gentoo3-150x30.png

for a working image URL but

  • it mis-corrects __images/gentoo3-150x30.png to http://__images/gentoo3-150x30.png and
  • setting it to //blog.hartwork.org/__images/gentoo3-150x30.png remains untouched but results in broken final URL http://blog.hartwork.org//blog.hartwork.org/__images/gentoo3-150x30.png on the blog itself (which is unexpected).

Without patching code, what are my options?
This behaviour is actually not new in 4.1 btw.

Change History (5)

#1 @hartwork
10 years ago

PS: /__images/gentoo3-150x30.png also ends up pointing to http:// rather than https:// if the blog master URL starts with http:// despite the user viewing the https:// version. I'd expect SSL-support from a relative link. Thanks!

Last edited 10 years ago by hartwork (previous) (diff)

#2 @SergeyBiryukov
10 years ago

  • Summary changed from [4.1] Managing Links: Broken handling of "Image Address" URLs? to Link Manager: Broken handling of "Image Address" URLs?

#3 follow-up: @DrewAPicture
10 years ago

  • Keywords dev-feedback close added
  • Summary changed from Link Manager: Broken handling of "Image Address" URLs? to Link Manager: Doesn't support relative URLs for "Image Address"

It definitely seems like the Link Manager doesn't support relative URLs. Not sure whether we're even still supporting enhancements to the this area since it was split off to a plugin a few releases ago.

#4 in reply to: ↑ 3 @SergeyBiryukov
10 years ago

  • Keywords dev-feedback close removed

Replying to DrewAPicture:

It definitely seems like the Link Manager doesn't support relative URLs. Not sure whether we're even still supporting enhancements to the this area since it was split off to a plugin a few releases ago.

All the plugin currently does is to enable the existing UI, so this seems like worthwhile fix.

#5 @tw2113
7 months ago

I think this issue was originally slightly mis-reported, or has somehow since changed from the time.

This version with the single forward slash at the start appears to work just fine now.

/__images/gentoo3-150x30.png

Without the slash at the front, it's generating the issue still, as well as trying to use the domain without the protocol.

I feel one solution could be with relative paths, check if the link image doesn't start with a single /, prepend for the user. However, trying to check for protocol-less domain may be a bit more code than preferred for a feature that is hidden for majority of the installs. Perhaps something like this for the first variation

} else { // If it's a relative path.
	$sep = '';
	if ( ! str_starts_with( $bookmark->link_image, '/' ) {
		$sep = '/';
	}
	$output .= '<img src="' . get_option( 'siteurl' ) . $sep . $bookmark->link_image . '"' . $alt . $title . ' />';
}

I think this could fix the most appropriate relative URL attempts.

Note: See TracTickets for help on using tickets.