material-ui-image icon indicating copy to clipboard operation
material-ui-image copied to clipboard

Resizing the image

Open wizhaaa opened this issue 5 years ago • 2 comments

How can I resize the image? When I use imageStyles attribute, it resizes the image but there is an empty white space of the original image. image

wizhaaa avatar Mar 26 '21 20:03 wizhaaa

okay, well I was able to change the width of the entire container (including the white space) by doing <style={ {width: 200} } but if I try to add height, or change only the height, it doesn't change at all. If I make it a width of 200, it just looks very squeezed. How can I change the width and height?

wizhaaa avatar Mar 26 '21 20:03 wizhaaa

Try to define aspectRatio and cover properties of the Image component:

const aspectRatio = postData.fotoportada.width / postData.fotoportada.height;
...
  <Image
    src={postData.fotoportada.url}
    aspectRatio={aspectRatio}
    cover
  />

frames75 avatar Apr 07 '21 08:04 frames75