-
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
Integrate PHPickerViewController in Media library #21343
Conversation
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
self.provider = provider | ||
} | ||
|
||
func export(onCompletion: @escaping (MediaExport) -> Void, onError: @escaping (MediaExportError) -> Void) -> Progress { |
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.
It works nearly identical to the existing MediaAssetExporter
(PHAsset
support) and shares some of the code with it.
Great post on NSItemProvider
: https://www.humancode.us/2023/07/08/all-about-nsitemprovider.html.
].map(\.identifier)) | ||
|
||
private func hasConformingType(_ type: UTType) -> Bool { | ||
provider.hasItemConformingToTypeIdentifier(type.identifier) |
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.
There is a nice UTType-based API but it’s available only in iOS 16 :(
import XCTest | ||
@testable import WordPress | ||
|
||
final class ItemProviderMediaExporterTests: XCTestCase { |
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.
MediaImageExporterTests
that’s used internally already has a bunch of tests, so we mostly rely on them and just test the integration.
I've been running some additional tests and encountered a limitation with RAW files. I added a RAW file to the Photos library (6000×4000px) and tried uploading it, but the file provider serves the downscaled version:
I tried uploading an even larger JPEG file (7200 × 5400px), and it worked perfectly and uploaded the full-resolution image. I have yet to find any documentation covering RAW support, so I'm asking around. There is a workaround: I'm not sure how important that scenario is, but it is still worth mentioning. WordPress doesn't support RAW files, so the app still has to transcode the image to JPEG. But the whole point of RAW files is to allow the users to pull out as many details from the photo as possible and create the JPEG they want. It's just not a thing that someone would want to upload a RAW file to WordPress and use the default iOS processing with no adjustments to the original photo. |
Finished manual testing and this is looking great! I have a couple of questions I left below. I'll go through the code separately and leave a review after that.
.heic image not uploading on the simSimulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-08-18.at.16.25.05.mp4Picker saying the location is included
Picker navigation bar transparency color |
It's a known issue with the flower image on the simulator. The item provider fails to export it on sims; nothing we can do. It's shame it's the very first one in the list 😃 |
The export options are a new feature added in iOS 17. Is that what you are testing with? There is no way to remove these options, but I think it's a great opportunity for us to remove some of the work that MediaImageExporter does. I kept it as is, so it fully matched the production version, but it seems problematic in a few ways:
I think, by default, the app should upload the image as is with no modifications whatsoever. Suppose we remove the "remove GPS data" feature from the Jetpack app in favor of the built-in feature on iOS 17. In that case, we can re-evaluate the decisions in Btw, there is a screenshot attached to the message that says 23.0 beta, but the new photo picker isn't included in it.
Exporting the item from |
Aha good catch, I didn't know that – it used to work at some point in the past.
Yep, I'm on iOS 17 on my iPhone.
I'm in favor of relying on the system "remove GPS data" if there's a way to ensure users don't accidentally upload GPS data by not realizing they need to manually turn it off at the system level.
The screenshot shows the system picker that's nested inside done.mov
Gotcha 👍 |
We can keep it in the app but avoid doing any extra processing if it's not there. Reading EXIF and verifying if it's there is a
Ah, got it. Yes, it makes sense it doesn't have the export options: it doesn't export the photos. |
I'm going to bump this to the next release because we'll be code freezing 23.1 today and this hasn't been approved yet. If this cannot wait two weeks and it's important that it makes it into this release, let me know and we'll organize a new beta once ready. |
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.
Part of #21190.
The changes affect both the WP and the Jetpack app.
Tests
Important
Permissions
Media Formats
You can add a WebP image from https://developers.google.com/speed/webp/gallery1: open it in the browser, long-tap and select “Save to Photos”.
Image Resizing
Removing GPS Data
You can use test-image-device-photo-gps.jpg for testing and macOS
Cmd+I
command to view photo EXIF.iCloud
Misc
Regression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary.UI Changes testing checklist: