react-image-magnify icon indicating copy to clipboard operation
react-image-magnify copied to clipboard

Dynamic height/width setting

Open josieoharrow opened this issue 5 years ago • 3 comments

It would be super helpful to be able to only set width or height and have the other value depend on the native height/width of the image... Is that even possible?

josieoharrow avatar Dec 16 '19 22:12 josieoharrow

the above requested feature would be super useful

divyanarla avatar Jan 17 '20 23:01 divyanarla

It would be super helpful to be able to only set width or height and have the other value depend on the native height/width of the image... Is that even possible? you could get the native height/width of the image and set them for the larger image for now, until the issue is addressed. like below function getImgSize(imgSrc) { var newImg = new Image();

newImg.onload = function() {
  var height = newImg.height;
  var width = newImg.width;
  alert ('The image size is '+width+'*'+height);
}

newImg.src = imgSrc; // this must be done AFTER setting onload

}

divyanarla avatar Jan 18 '20 00:01 divyanarla

It would be super helpful to be able to only set width or height and have the other value depend on the native height/width of the image... Is that even possible? you could get the native height/width of the image and set them for the larger image for now, until the issue is addressed. like below function getImgSize(imgSrc) { var newImg = new Image();

newImg.onload = function() {
  var height = newImg.height;
  var width = newImg.width;
  alert ('The image size is '+width+'*'+height);
}

newImg.src = imgSrc; // this must be done AFTER setting onload

}

Just left to understand how to use this function to dynamically set width, height for large images

Rim-777 avatar Mar 01 '20 22:03 Rim-777