sadovojav / yii2-image-thumbnail

Create image thumbnail Yii2 component
GNU General Public License v3.0
21 stars 12 forks source link

problem with work #2

Closed sunftec closed 8 years ago

sunftec commented 9 years ago

untitled

after install and config i cant use this..

sadovojav commented 9 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
    ]
]); ?>
sunftec commented 9 years ago

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

sadovojav commented 9 years ago

Try this in first parameter: Yii::getAlias('@web/uploads/dd.jpg') or '/uploads/dd.jpg'

sunftec commented 9 years ago

Again i see oops image

sadovojav commented 9 years ago

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)

sunftec commented 9 years ago

$config = [ 'id' => 'basic', 'language' => 'en', 'basePath' => dirname(DIR), 'bootstrap' => ['log' , 'thumbnail' ],

'components' => [

        'thumbnail' => [
                'class' => 'sadovojav\image\Thumbnail',
        ],

sadovojav commented 9 years ago

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
     ]
 ]); 
sunftec commented 9 years ago

thank you for help me. my image path : http://localhost/websitnews/web/uploads/dd.jpg

sadovojav commented 9 years ago

Please show me result this code:

echo Yii::getAlias('@webroot');
sunftec commented 9 years ago

ok!sorry... it : C:/Program Files (x86)/Ampps/www/websitnews/web

sadovojav commented 9 years ago

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.

sunftec commented 9 years ago

i have a lot space on this directory.. thank you for all answers..

sadovojav commented 9 years ago

@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: untitled-1

Try to do as well, with full path to image.