Make images be normal hyperlinks if middle/command clicked

pull/4/head
David Baker 2015-07-23 20:07:34 -07:00
parent 33f2955927
commit 2f9e3fcaea
1 changed files with 12 additions and 9 deletions

View File

@ -53,6 +53,8 @@ module.exports = React.createClass({
}, },
onClick: function(ev) { onClick: function(ev) {
var ms = ev.getModifierState();
if (ev.button == 0 && !ev.metaKey) {
ev.preventDefault(); ev.preventDefault();
var content = this.props.mxEvent.getContent(); var content = this.props.mxEvent.getContent();
var httpUrl = MatrixClientPeg.get().mxcUrlToHttp(content.url); var httpUrl = MatrixClientPeg.get().mxcUrlToHttp(content.url);
@ -61,6 +63,7 @@ module.exports = React.createClass({
width: content.info.w, width: content.info.w,
height: content.info.h height: content.info.h
}); });
}
}, },
render: function() { render: function() {
@ -75,7 +78,7 @@ module.exports = React.createClass({
return ( return (
<span className="mx_MImageTile"> <span className="mx_MImageTile">
<a href="#" onClick={this.onClick}> <a href={cli.mxcUrlToHttp(content.url)} onClick={this.onClick}>
<img src={cli.mxcUrlToHttp(content.url, 320, 240)} alt={content.body} style={imgStyle} /> <img src={cli.mxcUrlToHttp(content.url, 320, 240)} alt={content.body} style={imgStyle} />
</a> </a>
</span> </span>