-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 Optimize Images setting and enable it by default #21981
Conversation
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
case .medium: | ||
return NSLocalizedString("Medium", comment: "Indicates an image will use medium quality when uploaded.") | ||
case(.low): | ||
return NSLocalizedString("Low", comment: "Indicates an image will use low quality when uploaded.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80%, which is the current default, is considered optimal for web uploads. I would suggest going with 10% increments where 80% would be "Default", "Standard" or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kean for sharing this useful info 🙇 ! To be honest, I merely chose these quality values based on the ones we have in the Android version (reference). However, as you suggested, it might be interesting to use different values and more close to standards:
- Maximum/Very High: 100%.
- High: 90% (following this article, this JPEG quality gives a very high-quality image while gaining a significant reduction on the original 100% file size).
- Medium (default): 80% (following this article, this JPEG quality gives a greater file size reduction with almost no loss in quality).
- Low: 70% (following this article, 75% JPEG quality and lower begins to show obvious differences in the image, which can reduce your website user experience).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion applied in b6f0127.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I removed Very High
option as the above four options should be enough to set different quality settings.
@twstokes I'm assigning you as a reviewer in case you could take a preliminary review of the PR. I'm mostly looking for feedback regarding the approach, particularly for https://github.com/wordpress-mobile/WordPress-iOS/pull/21981/files#diff-45d2b2ed5b4684d81e4933cefdc647b6090ac127a7dd7e5ff11f5bdee894aa12R265-R280 related to animating table view cells. The PR is almost ready, I'm just waiting to incorporate some unit tests and Thanks for the help 🙇 ! |
The Very High option has been removed and the rest of values have been updated following more standard industry values (#21981 (comment)).
I'd like to share that I set this order based on the current implementation on Android.
Additionally, we already use this order in "Max Video Upload Size": However, we could inverse it for iOS if seems more suitable.
Good observation. I understand that the goal of presenting these two settings (i.e. Max Upload Size and Quality) is mainly to allow the user to customize the optimization. By default, the values will be the ones we consider optimal. Similar to my above comment, this implementation is based on what we currently have in the Android version. Following your comments @osullivanchris, we could have an option below "Optimize Images" named "Optimization Settings" where we'd present these two settings. WDYT?
Good point, I shared a similar comment in #21981 (comment). On Android this setting is displayed as "Maximum Image Size", I agree that size is usually more related to file size and not dimensions. Hence, we could rename the setting to something like "Max Image Upload Dimensions" or "Maximum Image Dimensions". WDYT? UPDATE: For videos we also use the word |
On it! 👀 |
To match the default values for image quality for iOS (see: wordpress-mobile/WordPress-iOS#21981), this commit changes the defaults for quality to the following: - Low = 70% - Medium = 80%
Heads up, @fluiddot: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @fluiddot! The code LGTM and I left some optional comments. 🚀
WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift
Outdated
Show resolved
Hide resolved
# Conflicts: # WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift
@twstokes I've applied the suggestions from your recent feedback. The PR is approved so I'd consider it ready to merge, but let me know if you'd like to perform a quick review before. Thanks for the help 🙇 ! |
return Int.max | ||
} else { | ||
return maxImageSizeSetting | ||
} | ||
} | ||
|
||
var imageQualityForUpload: ImageQuality { | ||
return imageOptimizationEnabled ? imageQualitySetting : .high |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When image optimization is disabled, the quality used is High
not Maximum
. This behavior matches the previous implementation where preferredImageCompressionQuality
was used:
@objc static let preferredImageCompressionQuality = 0.9 |
Description
This PR adds the Optimize Images setting to the App Settings screen, similar to what we have in the Android version.
Media Settings added/updated:
By default, the Optimize Image setting will be on and we'll apply the following default values to other media settings:
NOTE: If the user already previously set a value in Max Image Upload Size setting, it will remain that value.
Additionally, in the following upload flows, the app will ask the user to keep or disable the Optimize Images setting. The popup will only be shown once.
Media screen - Uploading using Choose from My Device/Take a Photo option.The media screen is now usingSiteMediaViewController
(Add Optimize Images setting and enable it by default #21981 (comment)).SiteMedia
) - Uploading using Choose from My Device/Take a Photo option.NOTE: This new screen is only available via the Media Modernization feature flag.
Screenshots
Video captures
ios-optimize-images-setting.mp4
ios-optimize-images-popup.mp4
To test
Default setting should be changed if it has never been set before
Default setting should not be changed if it has been set previously
Set original as max image upload size
Set max image upload size
Resize settings should function as expected
Compression settings should function as expected
Pop-up should be displayed in specific sources
Media Screen
My Site → Media
.Choose from My Device
option.Add
button.NOTE: The popup will be displayed independently to the media type. I.e. it could be shown when only uploading videos.
Gutenberg Editor
Preparation:
My Site → Posts
(or Pages).Image Block - From Device
Choose from device
option.Image Block - Take Photo
Take a Photo
option.Featured Image - From Device
...
button located on the top bar.Post Settings
options.Set Featured Image
.Choose from Device
option.Featured Image - Take Photo
...
button located on the top bar.Post Settings
options.Set Featured Image
.Take a Photo
option.Check events
Observe that the following events are sent:
APP_SETTINGS_OPTIMIZE_IMAGES_CHANGED
enabled
:True
if the app is optimizing images for uploads.APP_SETTINGS_MAX_IMAGE_SIZE_CHANGED
size
: Max size used.APP_SETTINGS_IMAGE_QUALITY_CHANGED
quality
: Quality value used.APP_SETTINGS_OPTIMIZE_IMAGES_POPUP_TAPPED
option
:on
if the user decided to leave image optimization on.off
if the user wants to disable it.Regression Notes
Potential unintended areas of impact
These changes mainly affect the App Settings screen and media upload flows.
What I did to test those areas of impact (or what existing automated tests I relied on)
MediaSettingsTests
MediaSettingsTests
to cover the new changes inMediaSettings
file.PR submission checklist:
RELEASE-NOTES.txt
if necessary.UI Changes testing checklist: