/** * @param Masthead $masthead * @param int $width * @param $timestamp * @return \Wikia\Vignette\UrlGenerator */ public static function getVignetteUrl(Masthead $masthead, $width, $timestamp) { $relativePath = $masthead->mUser->getGlobalAttribute(AVATAR_USER_OPTION_NAME); if ($relativePath) { if (strpos($relativePath, '/') !== false) { // custom avatar $url = self::vignetteCustomUrl($width, $relativePath, $timestamp); } else { // wikia-provided avatars $hash = FileRepo::getHashPathForLevel($relativePath, 2); $bucket = VignetteRequest::parseBucket($masthead->mDefaultPath); $relativePath = $hash . $relativePath; $url = self::buildVignetteUrl($width, $bucket, $relativePath, $timestamp, false); } } else { // default avatar $legacyDefaultUrl = $masthead->getDefaultAvatars('thumb/')[0]; $bucket = VignetteRequest::parseBucket($legacyDefaultUrl); $relativePath = VignetteRequest::parseRelativePath($legacyDefaultUrl); $url = self::buildVignetteUrl($width, $bucket, $relativePath, $timestamp, false); } return $url; }