public EntryForPictureDisplayContract GetCoverPictureThumb(int albumId) { var size = ImageSize.Thumb; // TODO: this all should be moved to DynamicImageUrlFactory return(repository.HandleQuery(ctx => { var album = ctx.Load(albumId); // If there is no picture, return empty. if (album.CoverPictureData == null || string.IsNullOrEmpty(album.CoverPictureMime)) { return EntryForPictureDisplayContract.Create(album, PermissionContext.LanguagePreference); } // Try to read thumbnail from file system. var data = album.Thumb; if (imagePersister.HasImage(data, size)) { var bytes = imagePersister.ReadBytes(data, size); return EntryForPictureDisplayContract.Create(album, data.Mime, bytes, PermissionContext.LanguagePreference); } // This should return the original image. return EntryForPictureDisplayContract.Create(album, PermissionContext.LanguagePreference); })); }
public EntryForPictureDisplayContract GetPictureThumb(int artistId) { var size = ImageSize.Thumb; return(repository.HandleQuery(ctx => { var artist = ctx.Load(artistId); if (artist.Picture == null || string.IsNullOrEmpty(artist.PictureMime)) { return EntryForPictureDisplayContract.Create(artist, PermissionContext.LanguagePreference); } var data = artist.Thumb; if (imagePersister.HasImage(data, size)) { var bytes = imagePersister.ReadBytes(data, size); return EntryForPictureDisplayContract.Create(artist, data.Mime, bytes, PermissionContext.LanguagePreference); } return EntryForPictureDisplayContract.Create(artist, PermissionContext.LanguagePreference); })); }