mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Fix profile images.
This commit is contained in:
parent
623dcde65c
commit
7d9d54d2ec
@ -6,11 +6,9 @@ namespace Jellyfin.Data.Entities
|
|||||||
{
|
{
|
||||||
public class ImageInfo
|
public class ImageInfo
|
||||||
{
|
{
|
||||||
public ImageInfo(string path, int width, int height)
|
public ImageInfo(string path)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
Width = width;
|
|
||||||
Height = height;
|
|
||||||
LastModified = DateTime.UtcNow;
|
LastModified = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,14 +18,10 @@ namespace Jellyfin.Data.Entities
|
|||||||
public int Id { get; protected set; }
|
public int Id { get; protected set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[MaxLength(512)]
|
||||||
|
[StringLength(512)]
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Width { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Height { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime LastModified { get; set; }
|
public DateTime LastModified { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ namespace Jellyfin.Server.Migrations.Routines
|
|||||||
{
|
{
|
||||||
ItemImageInfo info = mockup.ImageInfos[0];
|
ItemImageInfo info = mockup.ImageInfos[0];
|
||||||
|
|
||||||
user.ProfileImage = new ImageInfo(info.Path, info.Width, info.Height)
|
user.ProfileImage = new ImageInfo(info.Path)
|
||||||
{
|
{
|
||||||
LastModified = info.DateModified
|
LastModified = info.DateModified
|
||||||
};
|
};
|
||||||
|
@ -471,8 +471,17 @@ namespace MediaBrowser.Api.Images
|
|||||||
AssertCanUpdateUser(_authContext, _userManager, userId, true);
|
AssertCanUpdateUser(_authContext, _userManager, userId, true);
|
||||||
|
|
||||||
var user = _userManager.GetUserById(userId);
|
var user = _userManager.GetUserById(userId);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(user.ProfileImage.Path);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
// TODO: Log this
|
||||||
|
}
|
||||||
|
|
||||||
user.ProfileImage = null;
|
user.ProfileImage = null;
|
||||||
|
_userManager.UpdateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -639,6 +648,7 @@ namespace MediaBrowser.Api.Images
|
|||||||
IDictionary<string, string> headers,
|
IDictionary<string, string> headers,
|
||||||
bool isHeadRequest)
|
bool isHeadRequest)
|
||||||
{
|
{
|
||||||
|
info.Type = ImageType.Profile;
|
||||||
var options = new ImageProcessingOptions
|
var options = new ImageProcessingOptions
|
||||||
{
|
{
|
||||||
CropWhiteSpace = true,
|
CropWhiteSpace = true,
|
||||||
@ -886,9 +896,10 @@ namespace MediaBrowser.Api.Images
|
|||||||
// Handle image/png; charset=utf-8
|
// Handle image/png; charset=utf-8
|
||||||
mimeType = mimeType.Split(';').FirstOrDefault();
|
mimeType = mimeType.Split(';').FirstOrDefault();
|
||||||
var userDataPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
|
var userDataPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
|
||||||
|
user.ProfileImage = new Jellyfin.Data.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)));
|
||||||
|
|
||||||
await _providerManager
|
await _providerManager
|
||||||
.SaveImage(user, memoryStream, mimeType, Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)))
|
.SaveImage(user, memoryStream, mimeType, user.ProfileImage.Path)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
await _userManager.UpdateUserAsync(user);
|
await _userManager.UpdateUserAsync(user);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ namespace MediaBrowser.Controller.Drawing
|
|||||||
case ImageType.BoxRear:
|
case ImageType.BoxRear:
|
||||||
case ImageType.Disc:
|
case ImageType.Disc:
|
||||||
case ImageType.Menu:
|
case ImageType.Menu:
|
||||||
|
case ImageType.Profile:
|
||||||
return 1;
|
return 1;
|
||||||
case ImageType.Logo:
|
case ImageType.Logo:
|
||||||
return 2.58;
|
return 2.58;
|
||||||
|
@ -63,6 +63,11 @@ namespace MediaBrowser.Model.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The box rear.
|
/// The box rear.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BoxRear = 11
|
BoxRear = 11,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The user profile image.
|
||||||
|
/// </summary>
|
||||||
|
Profile = 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user