Skip to content

Commit

Permalink
Merge pull request #5 from dmyers/master
Browse files Browse the repository at this point in the history
Added ability to get cdn url for an asset.
  • Loading branch information
mmanos committed May 1, 2014
2 parents 778aad2 + 91fb406 commit 99dab0f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Mmanos/Casset/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,26 @@ public function image($source, $alt = null, $attributes = array())
$url = $source;

if (false === strstr($source, '://') && '//' !== substr($source, 0, 2)) {
$url = str_ireplace($this->public_path, '', $this->assets_path . '/' . ltrim($source, '/'));
$url = $this->cdn ? $this->cdn . $url : $url;
$url = $this->cdn($source);
}

return \HTML::image($url, $alt, $attributes);
}

/**
* Get the URL to the CDN for an asset.
*
* @param string $source
*
* @return string
*/
public function cdn($source)
{
$url = str_ireplace($this->public_path, '', $this->assets_path . '/' . ltrim($source, '/'));
$url = $this->cdn ? $this->cdn . $url : $url;
return $url;
}

/**
* Add a global dependency.
*
Expand Down

0 comments on commit 99dab0f

Please sign in to comment.