The actual URL is obtained by prepending either [[AssetBundle::$baseUrl]] or [[AssetManager::$baseUrl]] to the given asset path.
public getAssetUrl ( |
||
$bundle | the asset bundle which the asset file belongs to | |
$asset | string | the asset path. This should be one of the assets listed in [[AssetBundle::$js]] or [[AssetBundle::$css]]. |
return | string | the actual URL for the specified asset. |
public function getAssetUrl($bundle, $asset) { $url = parent::getAssetUrl($bundle, $asset); $absPath = \Yii::getAlias('@webroot') . $url; if (is_file($absPath)) { $mtime = filemtime($absPath); $md = md5($mtime); $v = substr($md, 0, 8); $url .= StringHelper::contains($url, '?') ? '&' : '?'; $url .= "v={$v}"; } return $url; }