There is a much cleaner pattern to do this type of operation. Here's some psuedo code:

var queryMap = { width : widthValue, height : heightValue, ... )
var query = createQuery(queryMap)
 
...

createQuery: function(queryMap) {
            if (!queryMap) {
                return null;
            }
            var pairs = [];
            for(var name in queryMap){
                var value = queryMap[name];
                pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
            }
            return pairs.join(",");
        }