Skip to content

Commit eb69a36

Browse files
authored
Fix issue where image previews in preview pane wouldn't work (#6144)
1 parent 28e484f commit eb69a36

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

Files/ViewModels/ItemViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,10 @@ await FilesystemTasks.Wrap(() => CoreApplication.MainView.DispatcherQueue.Enqueu
10721072
private async Task<ImageSource> GetItemTypeGroupIcon(ListedItem item, BaseStorageFile matchingStorageItem = null)
10731073
{
10741074
ImageSource groupImage = null;
1075-
if (item.PrimaryItemAttribute != StorageItemTypes.Folder)
1075+
if (item.PrimaryItemAttribute != StorageItemTypes.Folder || item.IsZipItem)
10761076
{
1077-
var headerIconInfo = await FileThumbnailHelper.LoadIconFromPathAsync(item.ItemPath, 76, ThumbnailMode.ListView);
1077+
var headerIconInfo = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(item.ItemPath, 64u);
1078+
10781079
if (headerIconInfo != null && !item.IsShortcutItem)
10791080
{
10801081
groupImage = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => headerIconInfo.ToBitmapAsync(), Windows.System.DispatcherQueuePriority.Low);

Files/ViewModels/Previews/ImagePreviewViewModel.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,10 @@ public ImageSource ImageSource
3030

3131
public override async Task<List<FileProperty>> LoadPreviewAndDetails()
3232
{
33-
FileRandomAccessStream stream = (FileRandomAccessStream)await Item.ItemFile.OpenAsync(FileAccessMode.Read);
34-
35-
// svg files require a different type of source
36-
if (!Item.ItemPath.EndsWith(".svg"))
37-
{
38-
var bitmap = new BitmapImage();
39-
ImageSource = bitmap;
40-
await bitmap.SetSourceAsync(stream);
41-
}
42-
else
43-
{
44-
var bitmap = new SvgImageSource();
45-
ImageSource = bitmap;
46-
await bitmap.SetSourceAsync(stream);
47-
}
33+
IRandomAccessStream stream = await Item.ItemFile.OpenAsync(FileAccessMode.Read);
34+
BitmapImage bitmap = new();
35+
await bitmap.SetSourceAsync(stream);
36+
ImageSource = bitmap;
4837

4938
return new List<FileProperty>();
5039
}

0 commit comments

Comments
 (0)