Skip to content

Commit a1a9705

Browse files
committed
change README.md
1 parent 2733074 commit a1a9705

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
# yii2-imagable
1+
# yii2-imagable
2+
3+
After extension is installed you need to setup imagable application component:
4+
```php
5+
'imagable' => [
6+
'class' => 'bl\imagable\Imagable',
7+
'imageClass' => 'bl\imagable\instances\CreateImageImagine',
8+
'categories' => [
9+
'origin' => false,
10+
'category' => [
11+
'galery' => [
12+
'origin' => true,
13+
],
14+
'avatars' => [
15+
'size' => [
16+
'big' => [
17+
'width' => 1000,
18+
'height' => 500,
19+
]
20+
]
21+
]
22+
]
23+
]
24+
...
25+
```

behaviors/CreateImageBehavior.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,24 @@ public function create($category, $path)
6161
//new image name created with class BaseName
6262
$imageName = $this->name->getName(FileHelper::getFileName($path));
6363
DirectoryHelper::create($newPath, true);
64-
//TODO:make size creator
65-
$image = '';
6664

65+
$image = '';
66+
//TODO:refactor here!
6767
foreach ($categoriesParam['category'] as $category) {
6868
if (isset($category['origin']) && $category['origin']) {
6969
$image = $imageName . "-origin." . FileHelper::getFileType($path);
7070
copy($path, implode(DIRECTORY_SEPARATOR, [$newPath, $image]));
71+
7172
} elseif (isset($categoriesParam['origin']) && $categoriesParam['origin']) {
7273
$image = $imageName . "-origin." . FileHelper::getFileType($path);
7374
copy($path, implode(DIRECTORY_SEPARATOR, [$newPath, $image]));
7475
}
76+
7577
$arr = isset($category['size']) ? array_merge($defaultCategoriesSize, $category['size']) : $defaultCategoriesSize;
7678
foreach ($arr as $sizeName => $size) {
7779
$image = $imageName . "-$sizeName." . FileHelper::getFileType($path);
7880
$this->imageCreator->thumbnail($path, $size['width'], $size['height']);
7981
$this->imageCreator->save(implode(DIRECTORY_SEPARATOR, [$newPath, $image]));
80-
// copy($path, implode(DIRECTORY_SEPARATOR, [$newPath, $image]));
8182
}
8283
}
8384

0 commit comments

Comments
 (0)