[wp-trac] [WordPress Trac] #30922: Link Manager: Doesn't support relative URLs for "Image Address"
WordPress Trac
noreply at wordpress.org
Fri Jun 28 23:25:09 UTC 2024
#30922: Link Manager: Doesn't support relative URLs for "Image Address"
--------------------------+---------------------
Reporter: hartwork | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: General | Version: 4.1
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+---------------------
Comment (by tw2113):
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30922#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list