summaryrefslogtreecommitdiff
path: root/searx/engines/flickr.py
diff options
context:
space:
mode:
authorCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-01-17 19:21:09 +0100
committerCqoicebordel <Cqoicebordel@users.noreply.github.com>2015-01-17 19:21:09 +0100
commitcb4a3fe598707fc42f86ea3f7bcf517dcd4db660 (patch)
treef5ee1ea08f2b491c58806e236664c23389b8ff21 /searx/engines/flickr.py
parentedd9d311809d8f6eab5109f9cd899e7989bb42d5 (diff)
Add thumbnails in images results
- Modify engines to create/fetch an URL for the thumbnails - Modify themes to show thumbnails instead of full images. In Courgette, the result is not very beautiful. Should we change it ?
Diffstat (limited to 'searx/engines/flickr.py')
-rw-r--r--searx/engines/flickr.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py
index 4dadd80a6..4040236e1 100644
--- a/searx/engines/flickr.py
+++ b/searx/engines/flickr.py
@@ -23,7 +23,7 @@ api_key = None
url = 'https://api.flickr.com/services/rest/?method=flickr.photos.search' +\
'&api_key={api_key}&{text}&sort=relevance' +\
- '&extras=description%2C+owner_name%2C+url_o%2C+url_z' +\
+ '&extras=description%2C+owner_name%2C+url_o%2C+url_n%2C+url_z' +\
'&per_page={nb_per_page}&format=json&nojsoncallback=1&page={page}'
photo_url = 'https://www.flickr.com/photos/{userid}/{photoid}'
@@ -65,6 +65,14 @@ def response(resp):
else:
continue
+# For a bigger thumbnail, keep only the url_z, not the url_n
+ if 'url_n' in photo:
+ thumbnail_src = photo['url_n']
+ elif 'url_z' in photo:
+ thumbnail_src = photo['url_z']
+ else:
+ thumbnail_src = img_src
+
url = build_flickr_url(photo['owner'], photo['id'])
title = photo['title']
@@ -80,6 +88,7 @@ def response(resp):
results.append({'url': url,
'title': title,
'img_src': img_src,
+ 'thumbnail_src': thumbnail_src,
'content': content,
'template': 'images.html'})