def create_relative_media_url(nav, url):
 parsed = urlparse(url)
 if parsed.netloc:
  return url
 if url.startswith(u'/'):
  base = u'/'
  url = url[1:]
 else:
  base = nav.url_context.base_path
 relative_base = nav.url_context.make_relative(base)
 if ((relative_base == u'.') and url.startswith(u'./')):
  relative_url = url
 else:
  relative_url = (u'%s/%s' % (relative_base, url))
 if ((nav.file_context.current_file.endswith(u'/index.md') is False) and (nav.url_context.base_path != u'/') and relative_url.startswith(u'./')):
  relative_url = (u'.%s' % relative_url)
 return relative_url

def create_relative_media_url ( nav , url ) : parsed = urlparse ( url ) if parsed . netloc : return url if url . startswith ( u'/' ) : base = u'/' url = url [ 1 : ] else : base = nav . url_context . base_path relative_base = nav . url_context . make_relative ( base ) if ( ( relative_base == u'.' ) and url . startswith ( u'./' ) ) : relative_url = url else : relative_url = ( u'%s/%s' % ( relative_base , url ) ) if ( ( nav . file_context . current_file . endswith ( u'/index.md' ) is False ) and ( nav . url_context . base_path != u'/' ) and relative_url . startswith ( u'./' ) ) : relative_url = ( u'.%s' % relative_url ) return relative_url
for a current page .