File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ class QwantImageSearch extends EngineRequest {
33 public function get_request_url () {
44 $ offset = $ this ->page * 5 ; // load 50 images per page
55 $ query = urlencode ($ this ->query );
6- return "https://api.qwant.com/v3/search/images?q= $ query&t=images&count=50&locale=en_us&offset= $ offset&device=desktop&tgp=3&safesearch=1 " ;
6+ $ url = "https://api.qwant.com/v3/search/images?q= $ query&t=images&count=50&locale=en_us&offset= $ offset&device=desktop&tgp=3 " ;
7+
8+ if (isset ($ _COOKIE ["safe_search " ]))
9+ $ url .= "&safesearch=1 " ;
10+
11+ return $ url ;
712 }
813
914 public function parse_results ($ response ) {
@@ -18,7 +23,7 @@ public function parse_results($response) {
1823
1924 for ($ i = 0 ; $ i < $ imgCount ; $ i ++)
2025 {
21- array_push ($ results ,
26+ array_push ($ results ,
2227 array (
2328 "thumbnail " => htmlspecialchars ($ imgs [$ i ]["thumbnail " ]),
2429 "alt " => htmlspecialchars ($ imgs [$ i ]["title " ]),
@@ -35,7 +40,7 @@ public static function print_results($results, $opts) {
3540
3641 foreach ($ results as $ result )
3742 {
38- if (!$ result
43+ if (!$ result
3944 || !array_key_exists ("url " , $ result )
4045 || !array_key_exists ("alt " , $ result ))
4146 continue ;
You can’t perform that action at this time.
0 commit comments