Use thumbnails instead of full-sized image

This commit is contained in:
Hexaitos 2024-11-10 15:20:27 +01:00
parent 77042d1c1e
commit d85136feb8
2 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,7 @@ def get_random_image(photos)
prop: 'imageinfo', prop: 'imageinfo',
titles: "#{random_photo}", # Specify the category title titles: "#{random_photo}", # Specify the category title
iiprop: 'url|user|extmetadata', iiprop: 'url|user|extmetadata',
iiurlwidth: 1000,
format: 'json' # Request response in JSON format format: 'json' # Request response in JSON format
} }
@ -25,6 +26,7 @@ def get_random_image(photos)
license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value'] license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value']
license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value'] license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value']
desc = info['imageinfo'].first['extmetadata']['ImageDescription']['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 end

View File

@ -1,6 +1,6 @@
<h1>Random bird of prey</h1> <h1>Random bird of prey</h1>
<a href="<%= image[:url] %>" target="_blank"> <a href="<%= image[:url] %>" target="_blank">
<img class="refsheet" src="<%= image[:url] %>"> <img class="refsheet" src="<%= image[:thumb] %>">
</a> </a>
<p><strong>Description:</strong> <%= image[:desc] %></p> <p><strong>Description:</strong> <%= image[:desc] %></p>
<p><strong>Photo by:</strong> <%= image[:user_url] %></p> <p><strong>Photo by:</strong> <%= image[:user_url] %></p>