Skip to content

Commit

Permalink
Closes #3 - updated file extenstion regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithkyle committed Nov 19, 2020
1 parent 6dca08c commit 4f2471a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed

- changed `$asset->url` to `$asset->getImageTransformSourcePath()` ([#3](https://github.com/codewithkyle/craft-jitter/issues/3))
- changed file extension regex pattern from `/(\..*)$/` to `/(\..{1,4})$/` ([#3](https://github.com/codewithkyle/craft-jitter/issues/3))

## [1.1.0] - 2020-10-26

Expand Down
10 changes: 5 additions & 5 deletions src/services/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ public function transformImage(array $params, bool $clientAcceptsWebp): array
$masterImage = $params['path'];
}

preg_match("/(\..*)$/", $asset->filename, $matches);
preg_match("/(\..{1,4})$/", $asset->filename, $matches);
$baseType = strtolower(ltrim($matches[0], "."));

// Build transform details
$transform = $this->getImageTransformSettings($params, $masterImage, $asset);
$uid = $this->buildTransformUid($transform);
$filename = preg_replace("/(\..*)$/", '', $asset->filename) . '-' . $uid;
$filename = preg_replace("/(\..{1,4})$/", '', $asset->filename) . '-' . $uid;

// Create S3 client (if possible)
$settings = [];
Expand Down Expand Up @@ -225,7 +225,7 @@ public function transformImage(array $params, bool $clientAcceptsWebp): array
$cleanName = preg_replace("/.*\//", '', $cleanName);
$response['url'] = "/jitter/" . $cleanName;
$response['type'] = 'local';
preg_match("/(\..*)$/", $existingFile, $matches);
preg_match("/(\..{1,4})$/", $existingFile, $matches);
$contentType = ltrim($matches[0], ".");
switch ($contentType)
{
Expand Down Expand Up @@ -253,7 +253,7 @@ public function transformImage(array $params, bool $clientAcceptsWebp): array
// Save the output
if ($s3)
{
preg_match("/(\..*)$/", $finalImage, $matches);
preg_match("/(\..{1,4})$/", $finalImage, $matches);
$finalImageType = $matches[0];
$uri = "/" . str_replace('\\', '/', $finalImage);
$uri = preg_replace("/.*\//", '', $uri);
Expand Down Expand Up @@ -288,7 +288,7 @@ public function transformImage(array $params, bool $clientAcceptsWebp): array
copy($finalImage, FileHelper::normalizePath($publicPath. DIRECTORY_SEPARATOR . $cleanName));
$response['url'] = "/jitter/" . $cleanName;
$response['type'] = 'local';
preg_match("/(\..*)$/", $finalImage, $matches);
preg_match("/(\..{1,4})$/", $finalImage, $matches);
$contentType = ltrim($matches[0], ".");
switch ($contentType)
{
Expand Down

0 comments on commit 4f2471a

Please sign in to comment.