From d85136feb8a58331b4f3d60d5ae9c94c543af9b8 Mon Sep 17 00:00:00 2001 From: Hexaitos Date: Sun, 10 Nov 2024 15:20:27 +0100 Subject: [PATCH] Use thumbnails instead of full-sized image --- get_random_image.rb | 4 +++- views/index.erb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/get_random_image.rb b/get_random_image.rb index 8681c8e..c647598 100644 --- a/get_random_image.rb +++ b/get_random_image.rb @@ -10,6 +10,7 @@ def get_random_image(photos) prop: 'imageinfo', titles: "#{random_photo}", # Specify the category title iiprop: 'url|user|extmetadata', + iiurlwidth: 1000, format: 'json' # Request response in JSON format } @@ -25,6 +26,7 @@ def get_random_image(photos) license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value'] license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value'] desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value'] + thumb = info['imageinfo'].first['thumburl'] - return {:user => user, :url => url, :license => license, :desc => desc, :license_url => license_url, :user_url => user_url} + return {:user => user, :url => url, :thumb => thumb, :license => license, :desc => desc, :license_url => license_url, :user_url => user_url} end \ No newline at end of file diff --git a/views/index.erb b/views/index.erb index 92403e6..8027669 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,6 +1,6 @@

Random bird of prey

- +

Description: <%= image[:desc] %>

Photo by: <%= image[:user_url] %>