How to NOT change the path/uri after applying a style? I'm working on a module. It uses an API to serve images. One of it's features is calling for a custom resolution image by GET request. So for example 

myapi.com/img4324342?w=22&amp;h=55.

I'm currently abusing the style function from the Image module. 

I call hook_preprocess_image() and if it detects my effect (my custom style that has my custom effect) it has to return a modified path. But the path get's malformed when I apply a style. I just want to have the original URI so I can use the information inside to construct a REST call. How to prevent that the URI changes after style a.k.a. how to return the original URI as Path?

Background:

It's a brand portal and I'm an intern making the drupal plugin. The company I work for doesn't want the images to be served from the Drupal hosting, only provided by the API. But they ALSO want that adding a different banner for example to every article is still done the same way you normally do: by adding a image style and adding it as a field to the content type

The $vars variabele from hook_preprocess_image() in json looks like this:

{
 "path":"?itok=D1zdawxe",
 "alt":null,
 "style_name":"thumbnail",
 "width":null,
 "height":null,
 "title":null,
 "attributes":[],
 "theme_hook_original":"image",
 "theme_hook_suggestions":[]
}


after applying any effect.

This means that when I don't apply any effect my Path (my Uri) is myscheme://img23423423432 and when I do apply ANY effect it get's malformed to random gibberish like ?itok=D1zdawxe
I've found a kinda nasty solution:

hook_preprocess_image_style(&amp;$variables) {
    $variables['uri'] = $variables['path'];
}

hook_preprocess_image(&amp;$vars) {
    if(array_key_exists('uri', $vars)) {
        $vars['path'] = $vars['uri'];
    }

    if(!isset($vars['style_name'])){
        return FALSE;
    }

    $image_styles = image_styles();

    foreach ($image_styles as $image_style_key =&gt; $image_style) {
        if ($vars['style_name'] == $image_style_key) {
            foreach ($image_style['effects'] as $effect_key =&gt; $effect) {
                if ($effect['name'] == 'myEffect') {
                    $vars['path'] = generateAPIURL($vars['path'], $effect['data']); //get baseURL from path and URL parameters from data
                    break;
                 }
            }
        }
    }
    return FALSE;
}