diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWMediaSearchWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWMediaSearchWidget.js index 5590ff6685..64d0479b54 100755 --- a/modules/ve-mw/ui/widgets/ve.ui.MWMediaSearchWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWMediaSearchWidget.js @@ -187,15 +187,20 @@ ve.ui.MWMediaSearchWidget.prototype.onMediaQueryDone = function ( source, data ) } for ( page in pages ) { - title = new mw.Title( pages[page].title ).getMainText(); - if ( !( title in this.titles ) ) { - this.titles[title] = true; - items.push( - new ve.ui.MWMediaResultWidget( - pages[page], - { '$': this.$, 'size': this.size } - ) - ); + // Verify that imageinfo exists + // In case it does not, skip the image to avoid errors in + // ve.ui.MWMediaResultWidget + if ( pages[page].imageinfo && pages[page].imageinfo.length > 0 ) { + title = new mw.Title( pages[page].title ).getMainText(); + if ( !( title in this.titles ) ) { + this.titles[title] = true; + items.push( + new ve.ui.MWMediaResultWidget( + pages[page], + { '$': this.$, 'size': this.size } + ) + ); + } } }