adjust default image provider
This commit is contained in:
parent
322e468eea
commit
e7d5532bee
|
@ -36,36 +36,42 @@ namespace MediaBrowser.Providers.FolderImages
|
|||
|
||||
if (view != null)
|
||||
{
|
||||
return GetImages(view.ViewType, cancellationToken);
|
||||
return GetImages(view.ViewType, view.UserId.HasValue, cancellationToken);
|
||||
}
|
||||
|
||||
var folder = (ICollectionFolder)item;
|
||||
return GetImages(folder.CollectionType, cancellationToken);
|
||||
return GetImages(folder.CollectionType, false, cancellationToken);
|
||||
}
|
||||
|
||||
private Task<IEnumerable<RemoteImageInfo>> GetImages(string viewType, CancellationToken cancellationToken)
|
||||
private Task<IEnumerable<RemoteImageInfo>> GetImages(string viewType, bool isUserSpecificView, CancellationToken cancellationToken)
|
||||
{
|
||||
var url = GetImageUrl(viewType);
|
||||
var url = GetImageUrl(viewType, isUserSpecificView);
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new List<RemoteImageInfo>
|
||||
if (!string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
new RemoteImageInfo
|
||||
{
|
||||
ProviderName = Name,
|
||||
Url = url,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
list.AddRange(new List<RemoteImageInfo>
|
||||
{
|
||||
new RemoteImageInfo
|
||||
{
|
||||
ProviderName = Name,
|
||||
Url = url,
|
||||
Type = ImageType.Primary
|
||||
},
|
||||
|
||||
new RemoteImageInfo
|
||||
{
|
||||
ProviderName = Name,
|
||||
Url = url,
|
||||
Type = ImageType.Thumb
|
||||
}
|
||||
});
|
||||
new RemoteImageInfo
|
||||
{
|
||||
ProviderName = Name,
|
||||
Url = url,
|
||||
Type = ImageType.Thumb
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Task.FromResult<IEnumerable<RemoteImageInfo>>(list);
|
||||
}
|
||||
|
||||
private string GetImageUrl(string viewType)
|
||||
private string GetImageUrl(string viewType, bool isUserSpecificView)
|
||||
{
|
||||
const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/MediaBrowser.Resources/master/images/folders/";
|
||||
|
||||
|
@ -102,6 +108,11 @@ namespace MediaBrowser.Providers.FolderImages
|
|||
return urlPrefix + "movies.png";
|
||||
}
|
||||
|
||||
if (isUserSpecificView)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return urlPrefix + "generic.png";
|
||||
}
|
||||
|
||||
|
@ -112,13 +123,6 @@ namespace MediaBrowser.Providers.FolderImages
|
|||
|
||||
public bool Supports(IHasImages item)
|
||||
{
|
||||
var view = item as UserView;
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
return !view.UserId.HasValue;
|
||||
}
|
||||
|
||||
return item is ICollectionFolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Server.Implementations.Collections
|
||||
{
|
||||
public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>, ICustomMetadataProvider<BoxSet>
|
||||
public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>
|
||||
{
|
||||
public CollectionImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
|
||||
{
|
||||
|
|
|
@ -15,8 +15,8 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Server.Implementations.Photos
|
||||
{
|
||||
public abstract class BaseDynamicImageProvider<T> : IHasChangeMonitor, IForcedProvider
|
||||
where T : IHasImages
|
||||
public abstract class BaseDynamicImageProvider<T> : IHasChangeMonitor, IForcedProvider, ICustomMetadataProvider<T>
|
||||
where T : IHasMetadata
|
||||
{
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
protected IProviderManager ProviderManager { get; private set; }
|
||||
|
|
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Server.Implementations.Photos
|
||||
{
|
||||
public class DynamicImageProvider : BaseDynamicImageProvider<UserView>, ICustomMetadataProvider<UserView>
|
||||
public class DynamicImageProvider : BaseDynamicImageProvider<UserView>
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
|
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Server.Implementations.Photos
|
||||
{
|
||||
public class PhotoAlbumImageProvider : BaseDynamicImageProvider<PhotoAlbum>, ICustomMetadataProvider<PhotoAlbum>
|
||||
public class PhotoAlbumImageProvider : BaseDynamicImageProvider<PhotoAlbum>
|
||||
{
|
||||
public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Server.Implementations.Playlists
|
||||
{
|
||||
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>, ICustomMetadataProvider<Playlist>
|
||||
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>
|
||||
{
|
||||
public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user