fixes for image links with multilang support

This commit is contained in:
Andy Miller
2015-09-15 10:12:30 -06:00
parent 565152dee0
commit dbe4bb87d0
3 changed files with 8 additions and 5 deletions

View File

@@ -133,7 +133,7 @@ trait ParsedownGravTrait
$path_parts = pathinfo($url['path']);
// get the local path to page media if possible
if ($path_parts['dirname'] == $this->page->url()) {
if ($path_parts['dirname'] == $this->page->url(false, false, false)) {
$url['path'] = $path_parts['basename'];
// get the media objects for this page
$media = $this->page->media();

View File

@@ -1236,7 +1236,7 @@ class Page
*
* @return string The url.
*/
public function url($include_host = false, $canonical = false)
public function url($include_host = false, $canonical = false, $include_lang = true)
{
/** @var Pages $pages */
@@ -1246,7 +1246,11 @@ class Page
$language = self::getGrav()['language'];
// get pre-route
$pre_route = $language->enabled() && $language->getActive() ? '/'.$language->getActive() : '';
if ($include_lang) {
$pre_route = $language->enabled() && $language->getActive() ? '/' . $language->getActive() : '';
} else {
$pre_route = '';
}
// get canonical route if requested
if ($canonical) {

View File

@@ -493,7 +493,6 @@ class Uri
$language_append = $active_language ? '/'.$active_language : '';
}
$pages_dir = $grav['locator']->findResource('page://');
$base_url = rtrim($grav['base_url'] . $grav['pages']->base(), '/') . $language_append;
@@ -556,7 +555,7 @@ class Uri
$instances = $grav['pages']->instances();
if (isset($instances[$page_path])) {
$target = $instances[$page_path];
$url_bits['path'] = $base_url . $target->route() . $filename;
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
return Uri::buildUrl($url_bits);
}