Skip to content

Fix: Include video and audio files in adaptive layout check#18322

Open
Josh65-2201 wants to merge 2 commits intofiles-community:mainfrom
Josh65-2201:Josh65/Fix-include-media-files-in-adaptive-layout-check
Open

Fix: Include video and audio files in adaptive layout check#18322
Josh65-2201 wants to merge 2 commits intofiles-community:mainfrom
Josh65-2201:Josh65/Fix-include-media-files-in-adaptive-layout-check

Conversation

@Josh65-2201
Copy link
Copy Markdown
Member

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

  1. Opened video, audio and image only folders they went to grid layout
  2. Opened just folders and mixed media (image and video/audio less that 85% of the total contents) they went to details layout

Added .ogg (.oga is the same format just different file extension) to the isAudio check. Was only in the isVideo check and as it can have video in it (although rarely) I have kept it there.

Note that the existing isMedia checks audio and video files in a folder. Since audio can have album art for the thumbnail I believe it's fine to have them also use grid layout

if (folderPercentage + miscPercentage > LargeThreshold)
return Layouts.Detail;
if (imagePercentage > ExtraLargeThreshold)
if (imagePercentage > ExtraLargeThreshold || mediaPercentage > ExtraLargeThreshold)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if statement should also make sure folderPercentage + miscPercentage > LargeThreshold is false. Otherwise, it will incorrectly switch to grid mode.

Copy link
Copy Markdown
Member Author

@Josh65-2201 Josh65-2201 Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell it checks how many folder and none media items there is compared to media/images, If that was above large threshold (>80%) then imagePercentage and mediaPercentage would be less than 20% combined and wouldn't pass ExtraLargeThreshold (>85%) anyway as it's already making a percentage based on how many total items there are in the folder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right.

One other thing, previously, when the image percentage was between 60% and 75%, the layout switched to Grid. It seems odd to me then that 75% to 85% would use Details, it would make more sense if we simply used Grid for anything above 60%.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtraLargeThreshold (85%) is what main currently uses, Do you want it changed to medium (I think that 60%)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes more sense, I'm just curious why the original behavior excluded 75% - 85%.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because it default was grid so it worked as intended in use

@yair100 yair100 added the changes requested Changes are needed for this pull request label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested Changes are needed for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants