fix for markdown images/links in pages with slug override

This commit is contained in:
Andy Miller
2015-01-23 17:09:37 -07:00
parent fad428b94b
commit 63a2ffc0b1
2 changed files with 5 additions and 6 deletions

View File

@@ -128,7 +128,6 @@ class Grav extends Container
}
}
// If no page found, fire event
$event = $c->fireEvent('onPageNotFound');

View File

@@ -210,16 +210,16 @@ trait ParsedownGravTrait
{
// if absolute and starts with a base_url move on
if ($this->base_url != '' && strpos($markdown_url, $this->base_url) === 0) {
$new_url = $markdown_url;
return $markdown_url;
// if its absolute and starts with /
} elseif (strpos($markdown_url, '/') === 0) {
$new_url = $this->base_url . $markdown_url;
return $this->base_url . $markdown_url;
} else {
$relative_path = $this->base_url . $this->page->route();
$real_path = $this->page->path() . '/' . parse_url($markdown_url, PHP_URL_PATH);
// If this is a 'real' filepath clean it up
if (file_exists($this->page->path() . '/' . parse_url($markdown_url, PHP_URL_PATH))) {
$relative_path = $this->base_url . preg_replace('/\/([\d]+\.)/', '/', str_replace($this->pages_dir, '', $this->page->path()));
// strip numeric order from markdown path
if (($real_path)) {
$markdown_url = preg_replace('/^([\d]+\.)/', '', preg_replace('/\/([\d]+\.)/', '/', trim(preg_replace('/[^\/]+(\.md$)/', '', $markdown_url), '/')));
}