function checkForMWimages(image_uri) {
  var retval = image_uri;
  if(image_uri.match(/\/wiki\/File:/)) { // guess it is any Mediawiki instance
    retval = image_uri.replace(/ /,"_")
      .replace(/\/File:/,'/Special:Redirect/file/')
      + "?width=" + popup_image_width;
  } else if (image_uri.match(/^File:/)) { // take File: for hosted at Wikimedia Commons
    retval = image_uri.replace(/ /,"_")
      .replace(/^File:/,'https://commons.wikimedia.org/wiki/Special:Redirect/file/')
      + "?width=" + popup_image_width;
  }

  return retval;
}
/*
 * checks if a image link points to a Mediawiki and if, returns link to thumbnail version of image
 */
checks if a image link points to a Mediawiki and if, returns link to thumbnail version of image
checks if a image link points to a Mediawiki and if returns link to thumbnail version of image
function checkForMWimages(image_uri) {
  var retval = image_uri;
  if(image_uri.match(/\/wiki\/File:/)) { 
    retval = image_uri.replace(/ /,"_")
      .replace(/\/File:/,'/Special:Redirect/file/')
      + "?width=" + popup_image_width;
  } else if (image_uri.match(/^File:/)) { 
    retval = image_uri.replace(/ /,"_")
      .replace(/^File:/,'https://commons.wikimedia.org/wiki/Special:Redirect/file/')
      + "?width=" + popup_image_width;
  }
  return retval;
}
function checkForMWimages ( image_uri ) { var retval = image_uri ; if ( image_uri . match ( / \/wiki\/File: / ) ) { retval = image_uri . replace ( / / , "_" ) . replace ( / \/File: / , '/Special:Redirect/file/' ) + "?width=" + popup_image_width ; } else if ( image_uri . match ( / ^File: / ) ) { retval = image_uri . replace ( / / , "_" ) . replace ( / ^File: / , 'https://commons.wikimedia.org/wiki/Special:Redirect/file/' ) + "?width=" + popup_image_width ; } return retval ; }
checks if a image link points to a Mediawiki and if, returns link to thumbnail version of image
checks if a image link points to a Mediawiki and if returns link to thumbnail version of image
// guess it is any Mediawiki instance // take File: for hosted at Wikimedia Commons