Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit aa3d7a9

Browse files
author
soliury
committed
fix the img show bugs in comments
1 parent 0973344 commit aa3d7a9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/components/htmlRender/CommentHtml.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ var styles = StyleSheet.create({
174174
paddingLeft: 20,
175175
borderLeftColor: '#3498DB',
176176
borderLeftWidth: 3
177+
},
178+
img:{
179+
width: width - 80,
180+
height: width - 80,
181+
resizeMode: Image.resizeMode.contain
177182
}
178183
})
179184

app/components/htmlRender/HtmlContent.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class HtmlContent extends Component {
8383

8484
_renderNode(node, index, parent, type) {
8585
var name = node.name
86+
87+
var imgStyle = (this.props.style && this.props.style.img) || styles.img
88+
8689
if (node.type == 'block' && type == 'block') {
8790
if (name == 'img') {
8891
var uri = node.attribs.src;
@@ -94,7 +97,7 @@ class HtmlContent extends Component {
9497
<Image
9598
key={index}
9699
source={{uri:uri}}
97-
style={styles.img}>
100+
style={imgStyle}>
98101
</Image>
99102
)
100103
}
@@ -108,7 +111,7 @@ class HtmlContent extends Component {
108111
value={this.props.content}
109112
stylesheet={this.props.style}
110113
onLinkPress={this._onLinkPress.bind(this)}
111-
renderNode={this._renderNode}
114+
renderNode={this._renderNode.bind(this)}
112115
/>
113116
)
114117
}

0 commit comments

Comments
 (0)