From 4b03102aa720406fd45c331ee9ac5165c0892308 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 9 Feb 2026 19:02:12 +0000 Subject: [PATCH] Display size for image search previews --- lib/brave_search/api.ex | 2 ++ lib/music_library_web/components/record_form.ex | 10 ++++++++++ test/brave_search/api_test.exs | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/brave_search/api.ex b/lib/brave_search/api.ex index 6ead2524..d0362774 100644 --- a/lib/brave_search/api.ex +++ b/lib/brave_search/api.ex @@ -20,6 +20,8 @@ defmodule BraveSearch.API do %{ thumbnail_url: get_in(result, ["thumbnail", "src"]), image_url: get_in(result, ["properties", "url"]), + width: get_in(result, ["properties", "width"]), + height: get_in(result, ["properties", "height"]), title: Map.get(result, "title", ""), source: Map.get(result, "source", "") } diff --git a/lib/music_library_web/components/record_form.ex b/lib/music_library_web/components/record_form.ex index 44112d3e..b139e15d 100644 --- a/lib/music_library_web/components/record_form.ex +++ b/lib/music_library_web/components/record_form.ex @@ -365,6 +365,16 @@ defmodule MusicLibraryWeb.Components.RecordForm do class="aspect-square w-full object-cover" loading="lazy" /> + + {result.width}×{result.height} + diff --git a/test/brave_search/api_test.exs b/test/brave_search/api_test.exs index dc1d0e6c..bb0d1ab4 100644 --- a/test/brave_search/api_test.exs +++ b/test/brave_search/api_test.exs @@ -19,7 +19,11 @@ defmodule BraveSearch.APITest do "results" => [ %{ "thumbnail" => %{"src" => "https://example.com/thumb.jpg"}, - "properties" => %{"url" => "https://example.com/full.jpg"}, + "properties" => %{ + "url" => "https://example.com/full.jpg", + "width" => 800, + "height" => 600 + }, "title" => "Test Image", "source" => "example.com" } @@ -32,6 +36,8 @@ defmodule BraveSearch.APITest do assert {:ok, [result]} = API.search_images("test query", [], @config) assert result.thumbnail_url == "https://example.com/thumb.jpg" assert result.image_url == "https://example.com/full.jpg" + assert result.width == 800 + assert result.height == 600 assert result.title == "Test Image" assert result.source == "example.com" end