Permalink
Browse files

Merge pull request #46 from kvakes/stacey

Absolute path for your media files, woohoo!
  • Loading branch information...
2 parents 1517c6c + fe228dd commit dfd30f65ae63f777444ece37c11c2b60f8ffe159 @kolber committed Apr 27, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 extensions/twig-extensions.inc.php
@@ -16,6 +16,7 @@ public function getName() {
public function getFilters() {
# custom twig filters
return array(
+ 'absolute' => new Twig_Filter_Method($this, 'absolute'),
'context' => new Twig_Filter_Method($this, 'context')
);
}
@@ -130,6 +131,14 @@ function sortby($object, $value) {
uasort($sorted, array($this, 'custom_str_sort'));
return $sorted;
}
+
+ #
+ # transforms relative path to absolute
+ #
+ function absolute($relative_path) {
+ # assume that all content lies in http://something.com/content/
+ return (($_SERVER['HTTPS'] ? 'https://' : 'http://')).$_SERVER['HTTP_HOST'].strstr($relative_path, '/content');
+ }
}

0 comments on commit dfd30f6

Please sign in to comment.