Skip to content

Commit

Permalink
Add flexibility to default img processor parameters
Browse files Browse the repository at this point in the history
Add compatibility with img backend urls that already use query
parameters.
  • Loading branch information
bago committed Dec 23, 2016
1 parent b1b391a commit 6d28f35
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ var applyBindingOptions = function(options, ko) {
var backEndMatch = imgProcessorBackend.match(/^(https?:\/\/[^\/]*\/).*$/);
var srcMatch = src.match(/^(https?:\/\/[^\/]*\/).*$/);
if (backEndMatch === null || (srcMatch !== null && backEndMatch[1] == srcMatch[1])) {
return imgProcessorBackend + "?src=" + encodeURIComponent(src) + "&method=" + encodeURIComponent(method) + "&params=" + encodeURIComponent(width + "," + height);
var queryParamSeparator = imgProcessorBackend.indexOf('?') == -1 ? '?' : '&';
return imgProcessorBackend + queryParamSeparator + "src=" + encodeURIComponent(src) + "&method=" + encodeURIComponent(method) + "&params=" + encodeURIComponent(width + "," + height);
} else {
console.log("Cannot apply backend image resizing to non-local resources ", src, method, width, height, backEndMatch, srcMatch);
return src + "?method=" + method + "&width=" + width + (height !== null ? "&height=" + height : '');
Expand Down

0 comments on commit 6d28f35

Please sign in to comment.