sjaakp / yii2-illustrated-behavior

Adds image to ActiveRecord
http://www.sjaakpriester.nl/software/illustrated
MIT License
43 stars 17 forks source link

all images end up on 240x240 #8

Closed philippfrenzel closed 8 years ago

philippfrenzel commented 9 years ago

Hi,

looks like I can upload the images, I manage to get the dimensions to set, but everytime I save, it converts the image to be 240x240:( And even "scales" them down, so proportions (aspect) get's lost:(

Thanks for your help!

philippfrenzel commented 9 years ago

sample: image

amlopezalonso commented 9 years ago

You should take into account aspectRatio both in Uploader and in Illustrated behavior. For instance:

public function behaviors(){
    return [
        [
            'class' => 'sjaakp\illustrated\Illustrated',
            ...
            'aspectRatio' => 0.75,
            ...
        ],
    ];
}

In form:

<?= $form->field($model, 'image')->widget(Uploader::className(), ['aspectRatio' => 0.75]) ?>
philippfrenzel commented 9 years ago

I agree, but as you can 'change' Ratio on switching e.g. Landscape it doesn't adopt ratio:( or am I doing something wrong?

amlopezalonso commented 9 years ago

Not sure as I haven't tested it but I guess if you want to have aspect ratio in Illustrated to change accordingly to the dynamic aspect ratio in Uploader you should include it as a field in your DB, then set aspectRatio in the behavior as the name of such attribute. Check aspectRatio definition in "Illustrated Options" chapter (float is for fixed aspect ratio -square in your case- string for attribute definition -hence dynamic, this should be what you are looking for-).

philippfrenzel commented 9 years ago

hmm, still don't get it to run... it's killing my pictures...:(