Skip to content

Commit

Permalink
2017-03-13 1203
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmcarvalho committed Mar 13, 2017
1 parent e8d398d commit e823972
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ExamplesTable extends Table
- **height:** (at least one) The crop image height. Default: **If width is set is the same**;
- **x:** (optional) The crop image x position based from left. Default: **Center**;
- **y:** (optional) The crop image y position based from top. Default: **Center**;
- **format:** Image format. It can be (jpg, png, gif). Default: `jpg`;
- **format:** Image format. It can be (`jpg`, `png`, `gif`, `same` (same as the original)). Default: `jpg`;
- **quality:** Image quality from 1 to 100. Default: `100`;
- **resize:** (optional) Changes the image size. Default: **Does not have**;
- **width:** (at least one) New image width. Default: **If height is set is automatic**;
Expand Down
15 changes: 14 additions & 1 deletion src/File/Writer/DefaultWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,18 @@ protected function getConfigFileFormat()
if (Hash::get($this->settings, 'image', false))
{
$fileExtension = Hash::get($this->settings, 'image.format', 'jpg');
return substr($fileExtension, 0, 1) === '.' ? $fileExtension : '.' . $fileExtension;
if (!in_array($fileExtension, ['jpg', 'png', 'gif', 'same']))
{
$fileExtension = 'jpg';
}
if ($fileExtension === 'same')
{
$fileExtension = pathinfo(Hash::get($this->fileInfo, 'name', 'err'), PATHINFO_EXTENSION);
return substr($fileExtension, 0, 1) === '.' ? $fileExtension : '.' . $fileExtension;
} else
{
return substr($fileExtension, 0, 1) === '.' ? $fileExtension : '.' . $fileExtension;
}
} else
{
$fileExtension = pathinfo(Hash::get($this->fileInfo, 'name', 'err'), PATHINFO_EXTENSION);
Expand All @@ -185,6 +196,8 @@ protected function createFilename($ifExistCreateNew = false)
$fileUniqidMoreEntropy = Hash::get($this->settings, 'more_entropy', true);
$this->filename = Hash::get($this->settings, 'filename', uniqid($filePrefix, $fileUniqidMoreEntropy)) . $this->getConfigFileFormat();
}

pr($this->getConfigFileFormat());exit;

return $this->filename;
}
Expand Down

0 comments on commit e823972

Please sign in to comment.