Skip to content

Commit

Permalink
Change retina behaviour to make the generated image cacheable
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Jan 17, 2016
1 parent e01ce72 commit 434a519
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function getPresetActions($preset_key, $file)
}
}

return [$preset, $preset_key, $file];
return [$preset, $file];
}

protected function generateRetinaAction($action)
Expand All @@ -110,9 +110,9 @@ protected function generateRetinaAction($action)
public function handleRequest($preset_key, $file)
{
//do it at the beginning for early validation
list($preset, $preset_key, $file) = $this->getPresetActions($preset_key, $file);
list($preset, $source_file) = $this->getPresetActions($preset_key, $file);

$original_file = $this->options['path_images_root'] . '/' . $this->imageUrl($file);
$original_file = $this->options['path_images_root'] . '/' . $this->imageUrl($source_file);
if (!is_file($original_file)) {
throw new Exceptions\NotFoundException('File not found');
}
Expand Down
6 changes: 2 additions & 4 deletions tests/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ public function testGetRetinaPreset()

$manager = $this->getManager(['presets' => ['200X@2x' => $original_preset, '200X' => []]]);

list($resolved_preset, $resolved_key, $resolved_file) = $this->setAccessible('getPresetActions')->invoke(
list($resolved_preset, $resolved_file) = $this->setAccessible('getPresetActions')->invoke(
$manager,
$original_preset_key,
$original_file
);

$this->assertEquals($original_preset, $resolved_preset);
$this->assertEquals('200X@2x', $resolved_key);
$this->assertEquals('file.jpg', $resolved_file);
}

Expand Down Expand Up @@ -142,14 +141,13 @@ public function testGenerateRetinaPreset()

$manager = $this->getManager(['presets' => ['200X' => $original_preset]]);

list($resolved_preset, $resolved_key, $resolved_file) = $this->setAccessible('getPresetActions')->invoke(
list($resolved_preset, $resolved_file) = $this->setAccessible('getPresetActions')->invoke(
$manager,
$original_preset_key,
$original_file
);

$this->assertEquals($generated_preset, $resolved_preset);
$this->assertEquals('200X@2x', $resolved_key);
$this->assertEquals('file.jpg', $resolved_file);
}

Expand Down

0 comments on commit 434a519

Please sign in to comment.