[wp-trac] Re: [WordPress Trac] #6998: Press This: Make UI look more
like admin area and fix relative URIs
WordPress Trac
wp-trac at lists.automattic.com
Tue May 20 01:33:40 GMT 2008
#6998: Press This: Make UI look more like admin area and fix relative URIs
-------------------------+--------------------------------------------------
Reporter: noel | Owner: ryan
Type: enhancement | Status: new
Priority: high | Milestone: 2.6
Component: Template | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment (by DD32):
> I also modified the function used to get images from a uri so it would
not mess up images with relative URIs.
Heres some code i currently use to determine the real URL of a relative
url'd image, Not sure if it'll be of any use though.
{{{
function im_url_join($one, $two){
//defaults:
$port = "80";
$scheme = $host = $path = '';
$url = parse_url($one);
extract($url);
if( ! empty($query) )
$query = "?$query";
$port = ($port != 80) ? ':' . $port : '';
if( substr($path, -1) != '/') //If path is to a file, direct back
to a folder.
$path = trailingslashit(rtrim(dirname($path),'\\'));
if( strpos($two, '://') > -1 ) // http:// .../...jpg
return $two;
if( $two[0] == '/' ) // /file.jpg
return "{$scheme}://{$host}{$port}{$two}";
if( substr($two,0, 3) == '../' ){
$path = trailingslashit(rtrim(dirname($path),'\\'));
$two = substr($two, 3);
return
im_url_join("{$scheme}://{$host}{$port}{$path}{$query}", $two);
}
return "{$scheme}://{$host}{$port}{$path}{$two}"; // simply
file.jpg
}
}}}
Example:
{{{
$one = 'http://google.com/pagename/';
$two = '../images/image.jpg';
$return = 'http://google.com/images/image.jpg
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/6998#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list