Closed sunftec closed 8 years ago
Wrong second parameter. It must be array
echo Yii::$app->thumbnail->url(YOUR_URL, [
'resize' => [
'width' => 320,
'height' => 200
]
]);
For example, I use this:
<?= Yii::$app->thumbnail->img($value->image, [
'thumbnail' => [
'width' => 320,
'height' => 230,
],
'placeholder' => [
'width' => 320,
'height' => 230
]
]); ?>
i try this:
Yii::$app->thumbnail->img('@web/uploads/dd.jpg', [
'thumbnail' => [
'width' => 400,
'height' => 400,
],
'placeholder' => [
'width' => 320,
'height' => 230
]
]);
but i see oops image!! not resize an show dd,jpg
Try this in first parameter: Yii::getAlias('@web/uploads/dd.jpg') or '/uploads/dd.jpg'
Again i see oops image
Can you show me full path from dd.jpg, and config this component. I think, that the problem is exactly on image path. Please, see basePath component parameter. Default: @webroot (in README this line is wrong)
$config = [
'id' => 'basic',
'language' => 'en',
'basePath' => dirname(DIR),
'bootstrap' => ['log' , 'thumbnail'
],
'components' => [
'thumbnail' => [
'class' => 'sadovojav\image\Thumbnail',
],
Give me full path from dd.jpg.
I want to help you, but i need more information.
By default (basePath) your upload directory should be placed in "web": /web/uploads
You can try this src, if your uploads directory in root /uploads
echo Yii::$app->thumbnail->img('../uploads/dd.jpg', [
'thumbnail' => [
'width' => 400,
'height' => 400
],
'placeholder' => [
'width' => 320,
'height' => 230
]
]);
thank you for help me.
my image path :
http://localhost/websitnews/web/uploads/dd.jpg
Please show me result this code:
echo Yii::getAlias('@webroot');
ok!sorry...
it : C:/Program Files (x86)/Ampps/www/websitnews/web
Hmmm...
Then the src must be: '/uploads/dd.jpg'
if it file are located there http://localhost/websitnews/web/uploads/dd.jpg
Maybe space in the path wrong handled.
I will try to reproduce your case.
i have a lot space on this directory.. thank you for all answers..
@sunftec Hi.I've reproduced your situation, but got a different result.
I replace string (line 240 (v2.0)/line 200 (v1.0)).
from: php $file = FileHelper::normalizePath(Yii::getAlias($this->basePath . '/' . $file));
to: `php``$file = FileHelper::normalizePath($file);```
echo '@webroot: -' . Yii::getAlias("@webroot") . '<br/>';
$src = 'C:/Program Files (x86)/Ampps/domains/test/frontend/web/uploads/dir (with) space/dd.jpg';
echo 'src - ' . $src . '<br/>';;
echo Yii::$app->thumbnail->img($src, [
'thumbnail' => [
'width' => 400,
'height' => 400
],
'placeholder' => [
'width' => 320,
'height' => 230
]
]);
die();
Result:
Try to do as well, with full path to image.
after install and config i cant use this..