You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Server.Impleme.../Photos/PhotoAlbumImageProvider.cs

45 lines
1.2 KiB

9 years ago
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
9 years ago
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.Linq;
9 years ago
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Photos
{
public class PhotoAlbumImageProvider : IDynamicImageProvider
{
public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
{
return new List<ImageType> { ImageType.Primary };
}
public Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
{
var album = (PhotoAlbum)item;
var image = album.Children
.OfType<Photo>()
.Select(i => i.GetImagePath(type))
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
9 years ago
return Task.FromResult(new DynamicImageResponse
{
Path = image,
HasImage = !string.IsNullOrEmpty(image)
});
}
9 years ago
public string Name
{
get { return "Image Extractor"; }
}
9 years ago
public bool Supports(IHasImages item)
{
return item is PhotoAlbum;
}
}
}