Skip to content

Commit

Permalink
Merge pull request #878 from dlcs/fix/thumbs_viewer_uses_v3
Browse files Browse the repository at this point in the history
Update Portal thumbnail viewer to request IIIF Image3 thumbnails
  • Loading branch information
griffri committed Jul 1, 2024
2 parents 49fbb77 + 73013e3 commit aa2f475
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/protagonist/Portal/Features/Spaces/Requests/GetImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using System.Threading.Tasks;
using API.Client;
using DLCS.Core.Collections;
using DLCS.Core.Settings;
using DLCS.HydraModel;
using DLCS.Web.Auth;
using IIIF.ImageApi.V3;
using MediatR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace Portal.Features.Spaces.Requests;

Expand All @@ -31,14 +33,17 @@ public class GetImageHandler : IRequestHandler<GetImage, GetImageResult?>
{
private readonly ILogger<GetImageHandler> logger;
private readonly IDlcsClient dlcsClient;
private readonly DlcsSettings dlcsSettings;
private readonly HttpClient httpClient;
private readonly string customerId;

public GetImageHandler(IDlcsClient dlcsClient, HttpClient httpClient, ILogger<GetImageHandler> logger, ClaimsPrincipal currentUser)
public GetImageHandler(IDlcsClient dlcsClient, HttpClient httpClient, ILogger<GetImageHandler> logger,
ClaimsPrincipal currentUser, IOptions<DlcsSettings> dlcsSettings)
{
this.logger = logger;
this.dlcsClient = dlcsClient;
this.httpClient = httpClient;
this.dlcsSettings = dlcsSettings.Value;
customerId = (currentUser.GetCustomerId() ?? -1).ToString();
}

Expand Down Expand Up @@ -67,11 +72,9 @@ public GetImageHandler(IDlcsClient dlcsClient, HttpClient httpClient, ILogger<Ge

private async Task<ImageService3?> GetImageThumbnailService(Image image)
{
if (image.ThumbnailImageService.IsNullOrEmpty()) return null;

try
{
var response = await httpClient.GetAsync($"{image.ThumbnailImageService}/info.json");
var response = await httpClient.GetAsync($"{dlcsSettings.ResourceRoot}thumbs/v3/{customerId}/{image.Space}/{image.ModelId}/info.json");
if (!response.IsSuccessStatusCode) return null;
return await response.Content.ReadFromJsonAsync<ImageService3>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/protagonist/Portal/Pages/Images/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task<IActionResult> OnGetAsync(int space, string image)

public string CreateSrc(Size size)
{
return $"{Image.ThumbnailImageService}/full/{size.Width},{size.Height}/0/default.jpg";
return $"{dlcsSettings.ResourceRoot}thumbs/v3/{Customer}/{Image.Space}/{Image.ModelId}/full/{size.Width},{size.Height}/0/default.jpg";
}

public string CreateUniversalViewerUrl(string singleAssetManifest)
Expand Down

0 comments on commit aa2f475

Please sign in to comment.