Simple Chrome extension: Open image in CMS using file name in url

In my strides to make work more efficient for my colleagues I’m trying to make an extension that enables editors to open images directly from front end, a task our CMS can’t do.

The idea: When editors see an image they need to edit, they right-click and chose “Open in CMS”. The extension picks up the filename (including file extension) and opens a new url in our CMS.

Front end image url is

Image in the CSM can be accessed using search so that

As a start I have tweaked an extension for Google Image search using this code:

function getClickHandler() {
  return function(info, tab) {

    var url = '' + info.srcUrl;{ url: url, width: 1024, height: 870 });

 * Context menu.
  "title" : "Find image in CMS",
  "type" : "normal",
  "contexts" : ["image"],
  "onclick" : getClickHandler()

This of course sends the full url into the CMS search so it doesn’t work. I have tried to combine it with another script I found:

var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);

But since I basically have no idea what I’m doing it doesn’t work. Any help is greatly appreciated! Thanks!