From 253564b8bf2a44146ef8b06a1f94ab25bc26d741 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 10 Dec 2014 15:12:50 +0100 Subject: [PATCH 1/2] add image filters --- README.md | 6 ++++++ lib/bing.js | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 310e87f..c979847 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ Bing.images("Ninja Turtles", function(error, res, body){ console.log(body); }, {skip: 50}); ``` +Adding filter(s) for the Image Search +```js +Bing.images("Ninja Turtles", function(error, res, body){ + console.log(body); +}, {imagefilters: 'Size:Small+Color:Monochrome'}); +``` ##### Specify Market Getting spanish results: diff --git a/lib/bing.js b/lib/bing.js index f545393..90cdb31 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -62,7 +62,8 @@ var Bing = function( options ) { + qs.stringify({ "Query": "'" + query + "'" }) + "&$top=" + opts.top + "&$skip=" + opts.skip - + (opts.market ? "&Market=%27" + opts.market + "%27" : ''); + + (opts.market ? "&Market=%27" + opts.market + "%27" : '') + + (opts.imagefilters ? "&ImageFilters=%27" + opts.imagefilters + "%27" : ''); request({ uri: reqUri, From ee6bc0448e28a2f521c3d9ea7298581e73df774d Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 10 Dec 2014 15:37:10 +0100 Subject: [PATCH 2/2] consider url encoded characters --- lib/bing.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bing.js b/lib/bing.js index 90cdb31..f9c52e5 100644 --- a/lib/bing.js +++ b/lib/bing.js @@ -63,7 +63,9 @@ var Bing = function( options ) { + "&$top=" + opts.top + "&$skip=" + opts.skip + (opts.market ? "&Market=%27" + opts.market + "%27" : '') - + (opts.imagefilters ? "&ImageFilters=%27" + opts.imagefilters + "%27" : ''); + + (opts.imagefilters + ? '&' + qs.stringify({ "ImageFilters": "'" + opts.imagefilters + "'" }) + : ''); request({ uri: reqUri,