talk-message-forms
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -68,20 +68,24 @@ (function() { | ||
render: function() { | ||
var height, imageHeight, imageWidth, maxWidth, reg, src, style, thumbnailUrl, width; | ||
var boundary, imageHeight, imageWidth, previewHeight, previewWidth, reg, src, style, thumbnailUrl; | ||
if (!this.props.attachment.data.thumbnailUrl.length) { | ||
return; | ||
} | ||
thumbnailUrl = this.props.attachment.data.thumbnailUrl; | ||
imageHeight = this.props.attachment.data.imageHeight; | ||
imageWidth = this.props.attachment.data.imageWidth; | ||
maxWidth = 240; | ||
if (imageWidth > maxWidth) { | ||
height = Math.round(imageHeight / (imageWidth / maxWidth)); | ||
width = maxWidth; | ||
thumbnailUrl = this.props.attachment.data.thumbnailUrl; | ||
boundary = 240; | ||
reg = /(\/h\/\d+)|(\/w\/\d+)/g; | ||
if (imageWidth > boundary) { | ||
previewHeight = Math.round(imageHeight / (imageWidth / boundary)); | ||
previewWidth = boundary; | ||
} else { | ||
height = imageHeight; | ||
width = imageWidth; | ||
previewHeight = imageHeight; | ||
previewWidth = imageWidth; | ||
} | ||
reg = /(h\/\d+)|(w\/\d+)/g; | ||
if (previewHeight > boundary) { | ||
previewWidth = Math.round(previewWidth / (previewHeight / boundary)); | ||
previewHeight = boundary; | ||
} | ||
if (reg.test(thumbnailUrl)) { | ||
src = thumbnailUrl.replace('h/200', "h/" + height).replace('w/200', "w/" + width); | ||
src = thumbnailUrl.replace(/(\/h\/\d+)/g, "/h/" + previewHeight).replace(/(\/w\/\d+)/g, "/w/" + previewWidth); | ||
} else { | ||
@@ -91,3 +95,3 @@ src = thumbnailUrl; | ||
style = { | ||
height: height | ||
height: previewHeight | ||
}; | ||
@@ -94,0 +98,0 @@ return div({ |
{ | ||
"name": "talk-message-forms", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "The Message Structure and Layout of jianliao.com", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34449
578