@@ -151,6 +151,15 @@ class AttachmentsList extends Component {
151151 ) ;
152152 }
153153
154+ /**
155+ * Sets event target src to null
156+ *
157+ * @param {Object } event
158+ */
159+ displayNone ( event ) {
160+ event . target . src = null ;
161+ }
162+
154163 /**
155164 * Renders the React component.
156165 *
@@ -187,6 +196,7 @@ class AttachmentsList extends Component {
187196 ) ;
188197
189198 let attachmentsRows = [ ] ;
199+ let regexImg = / i m a g e / ;
190200 for ( const key in this . state . attachments ) {
191201 if ( this . state . attachments . hasOwnProperty ( key ) ) {
192202 const item = this . state . attachments [ key ] ;
@@ -205,7 +215,26 @@ class AttachmentsList extends Component {
205215 </ div >
206216 < div className = 'col-md-8' >
207217 < div className = 'col-md-1' > < b > File: </ b > </ div >
208- < div className = 'col-md-11' > < i > { item . file_name } </ i > </ div >
218+ < div className = 'col-md-11' >
219+ < i > { item . file_name } </ i >
220+ { regexImg . test ( item . mime_type ) ?
221+ ( < img
222+ src = { this . props . baseURL +
223+ '/issue_tracker/Attachment' +
224+ '?ID=' + item . ID +
225+ '&file_hash=' + item . file_hash +
226+ '&issue=' + this . props . issue +
227+ '&filename=' + item . file_name +
228+ '&mime_type=' + item . mime_type
229+ }
230+ width = '100%'
231+ height = '100%'
232+ onError = { this . displayNone }
233+ >
234+ </ img > ) :
235+ null
236+ }
237+ </ div >
209238 </ div >
210239 </ div >
211240 < div className = 'row' >
0 commit comments