Created
August 23, 2017 11:11
-
-
Save Lazerproof/3722f4ff44c6fe922ab4fe40be6e9f80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adds file modified date as query string and returns URL to given asset. | |
* | |
* | |
* @param $relPath string File path relative to /site/templates/, such as "assets/css/style.css" | |
* @return string URL with cache busting query parameter | |
*/ | |
function assetUrl($relPath) | |
{ | |
$fullPath = wire()->config->paths->templates . $relPath; | |
$modified = filemtime($fullPath); | |
$url = wire()->config->urls->templates . $relPath . "?v=$modified"; | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment