Skip to content

Commit 334fc73

Browse files
committed
imagable add data provider
1 parent baefb91 commit 334fc73

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

BaseImagable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class BaseImagable extends Component
2727
public $imagesPath = '@webroot/images';
2828
public $baseTemplate = [];
2929
public $nameClass = 'bl\imagable\name\OriginName';
30+
public $dataProvider = [];
3031

3132
public function behaviors()
3233
{

behaviors/CreateImageBehavior.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ protected function saveImageInCategory($category, $path, $name)
121121

122122
foreach ($categorySizes as $sizeName => $size) {
123123
$image = "$imageName-$sizeName." . FileHelper::getFileType($path);
124+
if(property_exists($this->imageCreator, 'dataProvider')){
125+
$this->imageCreator->dataProvider = $this->owner->dataProvider;
126+
}
124127
$this->imageCreator->thumbnail($path, $size['width'], $size['height']);
125128
$this->imageCreator->save(implode(DIRECTORY_SEPARATOR, [$newPath, $image]));
126129
}

interfaces/CreateImageInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212
interface CreateImageInterface
1313
{
14-
1514
public function thumbnail($pathToImage, $width, $height);
1615

1716
public function save($saveTo);

name/CRC32Name.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CRC32Name extends BaseName
1212

1313
public function generate($baseName)
1414
{
15-
return uniqid(hash('crc32', $baseName));
15+
return hash('crc32', $baseName);
1616
}
1717

1818
}

0 commit comments

Comments
 (0)