mirror of
https://github.com/getgrav/grav.git
synced 2026-02-10 16:47:49 +01:00
fixes for image links with multilang support
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user