Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filesize in media item view controlller #22984

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

hoangatuan
Copy link

Fixes #22737

To test:

Regression Notes

  1. Potential unintended areas of impact: n/a
  2. What I did to test those areas of impact (or what existing automated tests I relied on): n/a
  3. What automated tests I added (or what prevented me from doing so): n/a

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

Attachments

Header Header
Simulator Screenshot - iPhone 15 Pro - 2024-04-10 at 17 34 16 Simulator Screenshot - iPhone 15 Pro - 2024-04-10 at 17 34 10

@kean
Copy link
Contributor

kean commented Apr 22, 2024

Hey, @hoangatuan. Thank you for addressing it, as it's been an outstanding item for a long time. However, it will require a bit more work. The issue is that the current Media.filesize is used only for local uploads, and so it's present only for files uploaded from the current device. In order to make it work for remote media assets, we'll need to extend the data model.

There is an open PR to add size to WordPresssKit wordpress-mobile/WordPressKit-iOS#647. Unfortunately, the site it returns is a pre-formatted string so there is no way to store it in Media.filesize. This is were the work currently stopped.

@@ -426,6 +427,25 @@ private struct MediaMetadataPresenter {

return (filename as NSString).pathExtension.uppercased()
}

var fileSize: String? {
guard let fileSizeInBytes = media.filesize as? Int else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest using ByteCountFormatter .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media: Add filesize
2 participants