Skip to content

Commit e317c87

Browse files
authored
Add "File Size" to Site Media Details (#24947)
* Add missing localization * Add File Size to Media Details * Show filesize only when available
1 parent 9766805 commit e317c87

File tree

2 files changed

+53
-23
lines changed

2 files changed

+53
-23
lines changed

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
26.5
22
-----
3-
* [**] Add "Status" field to the "Post Settings" screen to make it easier to move posts from one state to another [#24939]
3+
* [*] Add "Status" field to the "Post Settings" screen to make it easier to move posts from one state to another [#24939]
44
* [*] Add "Publish Date" back to "Post Settings" for draft and pending posts [#24939]
55
* [*] Use "Menlo" font for the password field to make it easier to distinguish between characters like `0` and `0` [#24939]
66
* [*] Add "Access" section to "Post Settings" [#24942]
7+
* [*] Add "File Size" to Site Media Details [#24947]
78
* [*] Add "Email to Subscribers" row to "Publishing" sheet [#24946]
89

910
26.4

WordPress/Classes/ViewRelated/Media/MediaItemViewController.swift

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ final class MediaItemViewController: UITableViewController {
5757
}
5858

5959
private func updateViewModel() {
60-
let titleRow = editableRowIfSupported(title: NSLocalizedString("Title", comment: "Noun. Label for the title of a media asset (image / video)"),
60+
let titleRow = editableRowIfSupported(title: Strings.title,
6161
value: mediaMetadata.title,
6262
action: editTitle())
63-
let captionRow = editableRowIfSupported(title: NSLocalizedString("Caption", comment: "Noun. Label for the caption for a media asset (image / video)"),
63+
let captionRow = editableRowIfSupported(title: Strings.caption,
6464
value: mediaMetadata.caption,
6565
action: editCaption())
66-
let descRow = editableRowIfSupported(title: NSLocalizedString("Description", comment: "Label for the description for a media asset (image / video)"),
66+
let descRow = editableRowIfSupported(title: Strings.description,
6767
value: mediaMetadata.desc,
6868
action: editDescription())
69-
let altRow = editableRowIfSupported(title: NSLocalizedString("Alt Text", comment: "Label for the alt for a media asset (image)"),
69+
let altRow = editableRowIfSupported(title: Strings.altText,
7070
value: mediaMetadata.alt,
7171
action: editAlt())
7272

@@ -103,16 +103,19 @@ final class MediaItemViewController: UITableViewController {
103103

104104
var rows = [ImmuTableRow]()
105105
rows.append(TextViewRow(title: Strings.url, details: media.remoteURL ?? ""))
106-
rows.append(TextRow(title: NSLocalizedString("File name", comment: "Label for the file name for a media asset (image / video)"), value: media.filename ?? ""))
107-
rows.append(TextRow(title: NSLocalizedString("File type", comment: "Label for the file type (.JPG, .PNG, etc) for a media asset (image / video)"), value: presenter.fileType ?? ""))
106+
rows.append(TextRow(title: Strings.fileName, value: media.filename ?? ""))
107+
rows.append(TextRow(title: Strings.fileType, value: presenter.fileType ?? ""))
108+
if let size = media.formattedSize {
109+
rows.append(TextRow(title: Strings.fileSize, value: size))
110+
}
108111

109112
switch media.mediaType {
110113
case .image, .video:
111-
rows.append(TextRow(title: NSLocalizedString("Dimensions", comment: "Label for the dimensions in pixels for a media asset (image / video)"), value: presenter.dimensions))
114+
rows.append(TextRow(title: Strings.dimensions, value: presenter.dimensions))
112115
default: break
113116
}
114117

115-
rows.append(TextRow(title: NSLocalizedString("Uploaded", comment: "Label for the date a media asset (image / video) was uploaded"), value: media.creationDate?.toMediumString() ?? ""))
118+
rows.append(TextRow(title: Strings.uploaded, value: media.creationDate?.toMediumString() ?? ""))
116119

117120
return rows
118121
}
@@ -142,7 +145,7 @@ final class MediaItemViewController: UITableViewController {
142145
private func handleDeletedMedia() {
143146
SVProgressHUD.setDefaultMaskType(.clear)
144147
SVProgressHUD.setMinimumDismissTimeInterval(1.0)
145-
SVProgressHUD.showError(withStatus: NSLocalizedString("This media item has been deleted.", comment: "Message displayed in Media Library if the user attempts to edit a media asset (image / video) after it has been deleted."))
148+
SVProgressHUD.showError(withStatus: Strings.mediaDeleted)
146149
navigationController?.popViewController(animated: true)
147150
}
148151

@@ -157,7 +160,7 @@ final class MediaItemViewController: UITableViewController {
157160
style: .plain,
158161
target: self,
159162
action: #selector(trashTapped))
160-
trashItem.accessibilityLabel = NSLocalizedString("Trash", comment: "Accessibility label for trash buttons in nav bars")
163+
trashItem.accessibilityLabel = Strings.trash
161164

162165
if media.blog.supports(.mediaDeletion) {
163166
navigationItem.rightBarButtonItems = [ shareItem, trashItem ]
@@ -197,7 +200,7 @@ final class MediaItemViewController: UITableViewController {
197200
controller.player?.play()
198201
})
199202
} else if let _ = error {
200-
SVProgressHUD.showError(withStatus: NSLocalizedString("Unable to load video.", comment: "Error shown when the app fails to load a video from the user's media library."))
203+
SVProgressHUD.showError(withStatus: Strings.unableToLoadVideo)
201204
}
202205
}
203206
}
@@ -263,9 +266,9 @@ final class MediaItemViewController: UITableViewController {
263266
}
264267

265268
let alertController = UIAlertController(title: nil,
266-
message: NSLocalizedString("Are you sure you want to permanently delete this item?", comment: "Message prompting the user to confirm that they want to permanently delete a media item. Should match Calypso."), preferredStyle: .alert)
267-
alertController.addCancelActionWithTitle(NSLocalizedString("Cancel", comment: "Verb. Button title. Tapping cancels an action."))
268-
alertController.addDestructiveActionWithTitle(NSLocalizedString("Delete", comment: "Title for button that permanently deletes a media item (photo / video)"), handler: { action in
269+
message: Strings.deleteConfirmation, preferredStyle: .alert)
270+
alertController.addCancelActionWithTitle(Strings.cancel)
271+
alertController.addDestructiveActionWithTitle(Strings.delete, handler: { action in
269272
self.deleteMediaItem()
270273
})
271274

@@ -280,7 +283,7 @@ final class MediaItemViewController: UITableViewController {
280283

281284
SVProgressHUD.setDefaultMaskType(.clear)
282285
SVProgressHUD.setMinimumDismissTimeInterval(1.0)
283-
SVProgressHUD.show(withStatus: NSLocalizedString("Deleting...", comment: "Text displayed in HUD while a media item is being deleted."))
286+
SVProgressHUD.show(withStatus: Strings.deleting)
284287

285288
let repository = MediaRepository(coreDataStack: ContextManager.shared)
286289
let mediaID = TaggedManagedObjectID(media)
@@ -289,9 +292,9 @@ final class MediaItemViewController: UITableViewController {
289292
try await repository.delete(mediaID)
290293

291294
WPAppAnalytics.track(.mediaLibraryDeletedItems, properties: ["number_of_items_deleted": 1], blog: self.media.blog)
292-
SVProgressHUD.showSuccess(withStatus: NSLocalizedString("Deleted!", comment: "Text displayed in HUD after successfully deleting a media item"))
295+
SVProgressHUD.showSuccess(withStatus: Strings.deleted)
293296
} catch {
294-
SVProgressHUD.showError(withStatus: NSLocalizedString("Unable to delete media item.", comment: "Text displayed in HUD if there was an error attempting to delete a media item."))
297+
SVProgressHUD.showError(withStatus: Strings.unableToDeleteMedia)
295298
}
296299
}
297300
}
@@ -304,14 +307,14 @@ final class MediaItemViewController: UITableViewController {
304307
guard let blog = self?.media.blog else { return }
305308
WPAppAnalytics.track(.mediaLibraryEditedItemMetadata, blog: blog)
306309
}, failure: { _ in
307-
SVProgressHUD.showError(withStatus: NSLocalizedString("Unable to save media item.", comment: "Text displayed in HUD when a media item's metadata (title, etc) couldn't be saved."))
310+
SVProgressHUD.showError(withStatus: Strings.unableToSaveMedia)
308311
})
309312
}
310313

311314
private func editTitle() -> ((ImmuTableRow) -> ()) {
312315
return { [weak self] row in
313316
let editableRow = row as! EditableTextRow
314-
self?.pushSettingsController(for: editableRow, hint: NSLocalizedString("Image title", comment: "Hint for image title on image settings."),
317+
self?.pushSettingsController(for: editableRow, hint: Strings.Hints.imageTitle,
315318
onValueChanged: { value in
316319
self?.title = value
317320
(self?.parent as? SiteMediaPageViewController)?.title = value
@@ -324,7 +327,7 @@ final class MediaItemViewController: UITableViewController {
324327
private func editCaption() -> ((ImmuTableRow) -> ()) {
325328
return { [weak self] row in
326329
let editableRow = row as! EditableTextRow
327-
self?.pushSettingsController(for: editableRow, hint: NSLocalizedString("Image Caption", comment: "Hint for image caption on image settings."),
330+
self?.pushSettingsController(for: editableRow, hint: Strings.Hints.imageCaption,
328331
onValueChanged: { value in
329332
self?.mediaMetadata.caption = value
330333
self?.reloadViewModel()
@@ -335,7 +338,7 @@ final class MediaItemViewController: UITableViewController {
335338
private func editDescription() -> ((ImmuTableRow) -> ()) {
336339
return { [weak self] row in
337340
let editableRow = row as! EditableTextRow
338-
self?.pushSettingsController(for: editableRow, hint: NSLocalizedString("Image Description", comment: "Hint for image description on image settings."),
341+
self?.pushSettingsController(for: editableRow, hint: Strings.Hints.imageDescription,
339342
onValueChanged: { value in
340343
self?.mediaMetadata.desc = value
341344
self?.reloadViewModel()
@@ -346,7 +349,7 @@ final class MediaItemViewController: UITableViewController {
346349
private func editAlt() -> ((ImmuTableRow) -> ()) {
347350
return { [weak self] row in
348351
let editableRow = row as! EditableTextRow
349-
self?.pushSettingsController(for: editableRow, hint: NSLocalizedString("Image Alt", comment: "Hint for image alt on image settings."),
352+
self?.pushSettingsController(for: editableRow, hint: Strings.Hints.imageAlt,
350353
onValueChanged: { value in
351354
self?.mediaMetadata.alt = value
352355
self?.reloadViewModel()
@@ -471,4 +474,30 @@ private struct MediaMetadata {
471474

472475
private enum Strings {
473476
static let url = NSLocalizedString("siteMedia.details.url", value: "URL", comment: "Title for the URL field")
477+
static let title = NSLocalizedString("siteMedia.details.title", value: "Title", comment: "Noun. Label for the title of a media asset (image / video)")
478+
static let caption = NSLocalizedString("siteMedia.details.caption", value: "Caption", comment: "Noun. Label for the caption for a media asset (image / video)")
479+
static let description = NSLocalizedString("siteMedia.details.description", value: "Description", comment: "Label for the description for a media asset (image / video)")
480+
static let altText = NSLocalizedString("siteMedia.details.altText", value: "Alt Text", comment: "Label for the alt for a media asset (image)")
481+
static let fileName = NSLocalizedString("siteMedia.details.fileName", value: "File Name", comment: "Label for the file name for a media asset (image / video)")
482+
static let fileType = NSLocalizedString("siteMedia.details.fileType", value: "File Type", comment: "Label for the file type (.JPG, .PNG, etc) for a media asset (image / video)")
483+
static let fileSize = NSLocalizedString("siteMedia.details.fileSize", value: "File Size", comment: "Label for the file size for a media asset (image / video)")
484+
static let dimensions = NSLocalizedString("siteMedia.details.dimensions", value: "Dimensions", comment: "Label for the dimensions in pixels for a media asset (image / video)")
485+
static let uploaded = NSLocalizedString("siteMedia.details.uploaded", value: "Uploaded", comment: "Label for the date a media asset (image / video) was uploaded")
486+
static let trash = NSLocalizedString("siteMedia.details.trash", value: "Trash", comment: "Accessibility label for trash buttons in nav bars")
487+
static let mediaDeleted = NSLocalizedString("siteMedia.details.mediaDeleted", value: "This media item has been deleted.", comment: "Message displayed in Media Library if the user attempts to edit a media asset (image / video) after it has been deleted.")
488+
static let unableToLoadVideo = NSLocalizedString("siteMedia.details.unableToLoadVideo", value: "Unable to load video.", comment: "Error shown when the app fails to load a video from the user's media library.")
489+
static let deleteConfirmation = NSLocalizedString("siteMedia.details.deleteConfirmation", value: "Are you sure you want to permanently delete this item?", comment: "Message prompting the user to confirm that they want to permanently delete a media item. Should match Calypso.")
490+
static let cancel = NSLocalizedString("siteMedia.details.cancel", value: "Cancel", comment: "Verb. Button title. Tapping cancels an action.")
491+
static let delete = NSLocalizedString("siteMedia.details.delete", value: "Delete", comment: "Title for button that permanently deletes a media item (photo / video)")
492+
static let deleting = NSLocalizedString("siteMedia.details.deleting", value: "Deleting...", comment: "Text displayed in HUD while a media item is being deleted.")
493+
static let deleted = NSLocalizedString("siteMedia.details.deleted", value: "Deleted!", comment: "Text displayed in HUD after successfully deleting a media item")
494+
static let unableToDeleteMedia = NSLocalizedString("siteMedia.details.unableToDeleteMedia", value: "Unable to delete media item.", comment: "Text displayed in HUD if there was an error attempting to delete a media item.")
495+
static let unableToSaveMedia = NSLocalizedString("siteMedia.details.unableToSaveMedia", value: "Unable to save media item.", comment: "Text displayed in HUD when a media item's metadata (title, etc) couldn't be saved.")
496+
497+
enum Hints {
498+
static let imageTitle = NSLocalizedString("siteMedia.hints.imageTitle", value: "Image title", comment: "Hint for image title on image settings.")
499+
static let imageCaption = NSLocalizedString("siteMedia.hints.imageCaption", value: "Image Caption", comment: "Hint for image caption on image settings.")
500+
static let imageDescription = NSLocalizedString("siteMedia.hints.imageDescription", value: "Image Description", comment: "Hint for image description on image settings.")
501+
static let imageAlt = NSLocalizedString("siteMedia.hints.imageAlt", value: "Image Alt", comment: "Hint for image alt on image settings.")
502+
}
474503
}

0 commit comments

Comments
 (0)