From 0ca58122a903fd297f9ed5c5834b883cc4f144a4 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 25 May 2017 06:13:27 -0600 Subject: [PATCH] added a relativePath() method --- system/src/Grav/Common/Page/Medium/Medium.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index d6f147510..fb57aed8c 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -146,6 +146,21 @@ class Medium extends Data implements RenderableInterface return $this->get('filepath'); } + /** + * Return the relative path to file + * + * @param bool $reset + * @return mixed + */ + public function relativePath($reset = true) + { + if ($reset) { + $this->reset(); + } + + return str_replace(GRAV_ROOT, '', $this->get('filepath')); + } + /** * Return URL to file. *