Skip to content

Commit

Permalink
Version: 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AntikCz committed May 29, 2015
1 parent d006763 commit 41b8c49
Show file tree
Hide file tree
Showing 76 changed files with 5,932 additions and 1,695 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

With composer:
```php
composer require webchemistry\images:1.2.2
composer require webchemistry\images:1.4
```

Config.neon:
Expand All @@ -22,11 +22,23 @@ class BasePresenter extends Nette\Application\UI\Presenter {
?>
```

Generate image´s address via Presenter:

```php
<?php

class GeneratePresenter extends BasePresenter {
use \WebChemistry\Images\Traits\TGenerator;
}
?>
```

##Usage

- [Configuring](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/CONFIGURING.md)
- [Generation of images in presenter](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/GENERATION.md)
- [Macros](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/NORMAL.md)
- [Responsive images](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/RESPONSIVE.md)
- [Manipulation in presenter](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/MANIPULATION.md)
- [Image upload](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/ADDONS.md)
- [Image upload](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/ADDONS.md)
- [Helpers](https://github.com/AntikCz/WebChemistry-Images/blob/master/manual/en/HELPERS.md)
19 changes: 19 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
extensions:
enabled: [Startup]
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webchemistry/images",
"type": "library",
"description": "Images storage for easily uploading, deleting and manilpulation.",
"description": "Images storage for easier uploading, deleting and manipulation.",
"license": ["GPL-3.0"],
"support": {
"email": "[email protected]",
Expand Down
5 changes: 1 addition & 4 deletions manual/en/ADDONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
For auto-uploading and auto-deleting images + preview image.

**Installation:**

```php
WebChemistry\Images\Addons\UploadControl::register();
```
Auto-installation via config

**Usage:**

Expand Down
10 changes: 10 additions & 0 deletions manual/en/CONFIGURING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ Default values in config.neon (All is optional):
```yaml
image:
wwwDir: %wwwDir%
registration:
texy: no
upload: yes
multiUpload: no
presenter: yes
assetsDir: 'assets'
noimage: 'noimage/noimage.png'
settings:
connectors: # For future update
upload:
label: 'Delete this image?'
helpers:
crop: WebChemistry\Images\Helpers\Crop
sharpen: WebChemistry\Images\Helpers\Sharpen
quality: WebChemistry\Images\Helpers\Quality
router:
mask: 'show-image/<name>[/<size>[/<flag>[/<noimage>]]]'
resize: no # Disallow create resized image
Expand Down
24 changes: 24 additions & 0 deletions manual/en/HELPERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Crop
Macro:
```html
{img 'name.jpg', '200x150|crop:50,50,50%,50%'}
```

```php
$imageStorage->get('name.jpg', '200x150|crop:50,50,50%,50%')
```

## Quality
```html
{img 'name.jpg', '200x150|quality:100'}
```

## Sharpen
```html
{img 'name.jpg', '200x150|sharpen'}
```

## Combination
```html
{img 'name.jpg', '200x150|sharpen|quality:50'}
```
12 changes: 3 additions & 9 deletions manual/en/MANIPULATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ class ImagePresenter extends BasePresenter {

public function after($form, $values) {
// From upload
$upload = $imageStorage->fromUpload($values->upload, 'namespace');
$upload = $imageStorage->saveUpload($values->upload, 'namespace', FALSE);

// From content
$upload = $imageStorage->fromContent($values->string, 'namespace');
$upload = $imageStorage->saveContent($values->string, 'namespace', FALSE);

// Namespace
$upload->setNamespace('namespace');
Expand All @@ -113,13 +113,7 @@ class ImagePresenter extends BasePresenter {
// Flags
$upload->setFlag('exact');

$upload->setCallback(function (Nette\Utils\Image $image) {
// Proccess

return $image;
});

// Uložení
// Save
$info = $upload->save();

(string) $info;
Expand Down
73 changes: 36 additions & 37 deletions src/Addons/GeneratePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,40 @@
use Nette, WebChemistry, Tracy;

class GeneratePresenter extends Nette\Application\UI\Presenter {

use WebChemistry\Images\Traits\TPresenter;

/** @var bool */
private $resize = FALSE;

public function __construct($resize = FALSE) {
$this->resize = (bool) $resize;
}

public function actionDefault($name, $size = NULL, $flag = NULL, $noimage = NULL) {
try {
$file = $this->imageStorage->create($name, $size, $flag, $noimage);
$info = $file->createImageInfo();
$info = $file->createInfoLink(is_dir(dirname($info->getAbsolutePath())) && $file->isResize() ? TRUE : $this->resize);
} catch (WebChemistry\Images\ImageStorageException $e) {
if (Tracy\Debugger::isEnabled()) {
throw $e;
} else {
$this->getHttpResponse()->setCode(404);

$this->terminate();
}
}

if ($info->isImageExists()) {
$image = Nette\Utils\Image::fromFile($info->getAbsolutePath());

$info = getimagesize($info->getAbsolutePath());

$image->send($info[2]);
} else {
$this->getHttpResponse()->setCode(404);

$this->terminate();
}
}

use WebChemistry\Images\Traits\TPresenter;

/** @var bool */
private $resize = FALSE;

public function __construct($resize = FALSE) {
$this->resize = (bool) $resize;
}

public function actionDefault($name, $size = NULL, $flag = NULL, $noimage = NULL) {
try {
$image = $this->imageStorage->get($name, $size, $flag, $noimage);

if (!$image->getInfo()->isImageExists() && !$this->resize) {
$info = $image->getOriginal();
} else {
$info = $image->getInfo();
}
} catch (\Exception $e) {
Tracy\Debugger::getLogger()
->log($e);

$this->error('Image error.');
}

if ($info->isImageExists()) {
$image = $info->getNetteImageClass();

$image->send($info->getImageType());
} else {
$this->error('Image not found.');
}

$this->terminate();
}
}
Loading

0 comments on commit 41b8c49

Please sign in to comment.