[1]I am using react-cropper to crop and upload an image. But I have been trying to reduce the size of "cropper-crop-box", that's the size of the selector in image without points, so I wanna decrease the size of that circle[react-cropper] and fix it's size, but initialAspectRatio is stopping me from setting it's size. Or if anyone knows how to decrease the size of that cropping circle with initialAspectRatio, that's also okay. Please help me with this.
<ImageCropper
style={{
height: 400,
width: "100%",
}}
ref={cropperRef}
cropmove={onCropMove}
zoomTo={0.5}
initialAspectRatio={1}
aspectRatio={NaN}
src={URL.createObjectURL(file[0])}
viewMode={2}
minCropBoxHeight={50}
minCropBoxWidth={5}
background={false}
responsive={true}
autoCropArea={2}
checkOrientation={false}
onInitialized={(instance) => {
setCropper1(instance);
}}
guides={false}
cropBoxMovable={true}
movable={true}
/>
Related
When creating a bubble chart, such as https://www.amcharts.com/demos/bubble-chart/, is it possible to ensure the chart area/grid is square without specifying the chart div width and height? I'm hoping it could be somewhat responsive. No matter what the window size, the chart 's grid is square. It would need to take into consideration any axis labels.
I'm using React/TypeScript. Thanks!
After struggling with amchart settings to no avail, the following solution works. However, seems like there should be away to do in with chart settings.
This article explains how to maintain a specific aspect ratio for images. I simply adopted it for the bubble chart.
<div style={{ position: 'relative', paddingTop: '93%' }}>
<div id={chartId} style={{ position: 'absolute', top: 0, left: 0, height: '100%', width: '100%' }}></div>
</div>
Create a container div with relative positioning and the top padding to the correct aspect ratio
Create the chart div as a child with absolute positioning
Render the page
Take a screenshot, paste it in your favorite image editor
Measure the pixels
Recalculate the top padding
For my chart, which has axis text on the left and bottom, 93% was perfect. Now, no matter the page width or device, the grid is always square. HTH.
I have a 1242 X 450 image, which I’d like to display on a 1x 2x and 3x devices. The current code, which I have, works fine for 3x devices but I see that the edge of the image gets cropped on a 2x device and possible on a 1x device too.
In code I am setting width to 414 and height to 150 (because 1242 X 450 /3x)
Is there any way I can fix it?
The image is inside a list view
<View style={styles.row}>
<Image
style={styles.featureImage}
source={{
uri: this.props.image_src
}}/>
</View>
const styles = StyleSheet.create({
row: {
alignItems: 'center',
backgroundColor: 'lightgrey',
flexDirection: 'row',
margin: 6,
},
featureImage: {
height: 150,
width: 414
}
});
You don't need to deal with image's size. You just give width and height property properly.
import Platform and get width and height of device.https://facebook.github.io/react-native/docs/dimensions.html
var {scrHeight, scrwidth} = Dimensions.get('window');
define an image container style
imageContainer = {
width:scrwidth/5,
height:scrHeight/5,
}
define image style and use resizeMode for image
resizeMode enum('cover', 'contain', 'stretch', 'repeat', 'center')
imageStyle={
flex:1,
}
<View style={styles.imageContainer }>
<Image style={styles.imageStyle} resizeMode={'contain'}>
</Image>
</View>
No matter how big the image is it will cover screenWidth/5 X screenHeight/5.
If your image has high resolution and device is not the image will be compressed in the contrary case it will be stretched. Both case especially second one if there is a big difference between image resolution and area which is left for image you will have bad image vision in your app. To avoid this situation you can add different sizes of the same image.
add
└── img
├── apple#1x.png 100x100 (resolutions are random)
└── apple#2x.png 150x150
apple#3x.png 175x175
https://facebook.github.io/react-native/docs/images.html
If you do so proper image will be chosen by react automatically. Images are chosen according to dpi of device. If your device has nice resolution you get bigger image if not so smaller image. This situation mostly works except devices having big sizes and low resolutions( some android tablets). In this case according to dpi image will be probably smallest image so there will be a bad quality.
I try to create a View with an Image and a Text component that wraps around the Image component.
My styling:
textContainer: {
flexDirection: 'row',
},
text: {
flex: 10,
},
image: {
flex:1,
height: 180,
width: 150,
margin: 10,
borderColor: '#ccc',
borderWidth: 1,
}
My component:
<ScrollView style={styles.contentContainer} >
{this.props.content.title_1 ? <Text style={styles.title}>{this.props.content.title_1}</Text> : null}
<View style={styles.textContainer}>
{this.props.content.text_1 ? <Text style={styles.text}>{this.props.content.text_1}</Text> : null}
{this.props.content.image_1 ? <Image width={null} height={null} style={styles.image} source={this.props.content.image_1} /> : null}
</View>
</ScrollView>
This is what the result: (not wrapping at all haha)
In the image beneath here, I quickly hacked the little image into the text. But I can't get the text to be wrapped around..
I hope anyone can help me in the right direction!
This is really hard but there is one weird way to do this.. Try the following. It worked for me but place I am doing this is too deep in the other views.:
<Text>
<View style={{width:400, height:100, flex:1, flexDirection:'row'}}>
<Image source={require('')}/>
<Text>Your Content Here</Text>
</View>
</Text>
Good luck. Please put a comment letting us know if it worked.
On android you cannot place a View inside Text, but you can place an Image, here is an example:
<Text>
<Image source="" />
<Text> Insert your text here </Text>
</Text>
Although this is an old post, I'll add this because I have recently had this problem and found a totally different approach that works for me. I don't have the code to hand (I can get it if anyone wants it), but the principle was this:
Requirement: to have a picture in the top left corner of the screen that takes up about half the screen width, with text starting to the right of it and then continuing beneath it for the whole width of the screen.
In XML, create a RelativeLayout containing an ImageView (IV) on the left and a TextView (TVA), set to wrap content, on the right. Then create another TextView (TVB) to sit below the Relative Layout. TVA is for the text beside the image and TVB for the text beneath it.
Put your image in IV. Then measure the height of IV in pixels (dpi). Call this height IVh
Put some of your text in TVA. As long as there is enough text to wrap over several lines, it doesn't really matter how much. Then measure the height of TVA in pixels. Call this height TVh
Compare IVh with TVh. If IVh=TVh then you have just the right amount of text to sit alongside your image. If TVh = IVh x 2 then you have twice as much text as you should have. And so on.
Adjust the number of words accordingly and put the right number into TVA, replacing what was there, then put the rest of the text in TVB.
You will need to play with margins and padding to allow an adequate margin around the image. Also, in steps 3 and 4 after you have put your image into ImageView or your text into TextView, you will need a delay before measuring the heights, to allow the display to be created - otherwise the measurement will be done too soon, before there is anything on the screen, and will return a height of zero. I found 200 milliseconds quite adequate and it's too fast for the user to notice a delay.
As you can see in http://thefreefallband.com/super in the last post there's an image too big for almost every computer. Is there anyway to pu t a limit to the images in wordpress in width?
If there isn't, how can i resize it via html code without losing the proportion?
A really simple CSS fix would be:
.post img {
max-width: 100%;
height: auto;
}
You can declare the sizes of images the WP makes automatically when you upload them to the Media Library by going to 'Settings -> Media'. Note that while Thumnial Size will crop your image to the exact size you specify, Medium Size and Large Size will keep the aspect ratio of your image, while resizing it to fit your specified max height/width.
If they are not good for you, you can add you own image size in functions.php
add_image_size( $name, $width, $height, $crop );
See the codex for more informaion.
When calling an image, depending on the function your are using, you can specify either one of the defined image sizes, or a maximum height/width (WP will find the closest match if you do this).
Assuming your are using the post featured image -
if(has_post_thumbnail( $post_id )) :
the_post_thumbnail( $size, $attr );
endif;
See the codex for has_post_thumbnail() and the_post_thumbnail() for more informaion.
I need help finding where and how to change the size and crop of a featured image within a post. I've looked in functions.php and init.php, but with no success. I'm using a child theme of the inLine theme.
The current height is set for 130px.
I've tried changing the css, but that only stretches the image.
Do this in functions.php:
add_image_size( 'name-of-your-image-size', 600, 300, true );
Or if you'd rather use a plugin-
http://wordpress.org/extend/plugins/additional-image-sizes-zui/
And then in your post, retrieve it like so in your single.php or loop:
<?php the_post_thumbnail('name-of-your-image-size'); ?>
In your functions.php, paste one of these and adjust pixel width and height to your liking:
set_post_thumbnail_size( 100, 100 ); // 100 pixels wide by 100 pixels tall, box resize mode
OR:
set_post_thumbnail_size( 100, 100, true ); // 100 pixels wide by 100 pixels tall, hard crop mode