/**
  * @param string $vignetteResult
  * @param string $legacyDefinition
  * @dataProvider legacyThumbDefinitions
  */
 public function testApplyLegacyThumbDefinition($vignetteResult, $legacyDefinition)
 {
     $this->mockGlobalVariable('wgVignetteUrl', $this->vignetteUrl);
     $baseUrl = "{$this->vignetteUrl}/tests/images/a/ab/filename.jpg/revision/latest";
     $generator = VignetteRequest::fromConfigMap(['relative-path' => 'a/ab/filename.jpg', 'bucket' => 'tests', 'timestamp' => '123', 'domain-shard-count' => 1]);
     $actual = VignetteRequest::applyLegacyThumbDefinition($generator, $legacyDefinition)->url();
     $this->assertEquals("{$baseUrl}/{$vignetteResult}", $actual);
 }
 public function build()
 {
     if (!$this->parseUrl()) {
         $this->reportError('unable to parse url');
     }
     $isArchive = $this->urlParts['revision'] != \Wikia\Vignette\UrlGenerator::REVISION_LATEST;
     if ($isArchive) {
         $this->timestamp = $this->urlParts['revision'];
     }
     $generator = VignetteRequest::fromConfigMap(['bucket' => $this->urlParts['bucket'], 'relative-path' => $this->urlParts['relativePath'], 'timestamp' => $this->timestamp, 'path-prefix' => $this->pathPrefix, 'is-archive' => $isArchive]);
     if (!$this->asOriginal && isset($this->urlParts['thumbnailDefinition'])) {
         $this->addThumbDefinition($generator);
     }
     return $generator;
 }
Example #3
0
 /**
  * @return \Wikia\Vignette\UrlGenerator object
  */
 public function getUrlGenerator()
 {
     return VignetteRequest::fromConfigMap(['is-archive' => false, 'timestamp' => $this->getTimestamp(), 'relative-path' => $this->getUrlRel(), 'bucket' => $this->getBucket(), 'path-prefix' => $this->getPathPrefix()]);
 }
 private static function buildVignetteUrl($width, $bucket, $relativePath, $timestamp, $avatarImageType = true)
 {
     $config = ['bucket' => $bucket, 'timestamp' => $timestamp, 'relative-path' => $relativePath];
     $avatar = VignetteRequest::fromConfigMap($config)->scaleToWidth($width);
     if (intval($width) > self::PERFORMANCE_JPEG_THRESHOLD) {
         $avatar->jpg();
     }
     if ($avatarImageType) {
         $avatar->avatar();
     }
     return $avatar->url();
 }
Example #5
0
 /**
  * Get the Vignette\UrlGenerator for this file.
  *
  * @return \Wikia\Vignette\UrlGenerator
  *
  */
 public function getUrlGenerator()
 {
     $timestamp = $this->isOld() ? $this->getArchiveTimestamp() : $this->getTimestamp();
     return VignetteRequest::fromConfigMap(['is-archive' => $this->isOld(), 'timestamp' => $timestamp, 'relative-path' => $this->getHashPath() . rawurlencode($this->getName()), 'bucket' => $this->getBucket(), 'path-prefix' => $this->getPathPrefix()]);
 }