-
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
Media: Add support for remaining asset types #21664
Conversation
let scale = UIScreen.main.scale | ||
var targetSize = targetSize | ||
if remoteURL.isGif { | ||
targetSize = targetSize |
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.
Downscaling from 3x to 1x turned out to be a bit too much.
import Combine | ||
import Gifu | ||
|
||
final class SiteMediaCollectionCell: UICollectionViewCell { |
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.
I don't know why it didn't register the rename 😞
📲 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.
|
20d6bb2
to
669c2e4
Compare
Next steps is to test it with self-hosted sites, add some unit tests. I expect there are going to be some complication with video thumbnails. |
Generated by 🚫 dangerJS |
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.
Works as described!
When uploading files, the cell doesn't update to include the filename once it's finished uploading the file. Pull to refresh doesn't update the cells either. You have to exit the screen then come back to see the correct icon / filename.
RPReplay_Final1696427175.MP4
WordPress/Classes/ViewRelated/Media/SiteMedia/Views/SiteMediaCollectionCellViewModel.swift
Outdated
Show resolved
Hide resolved
@@ -299,6 +311,9 @@ private extension Data { | |||
// JPEG magic numbers https://en.wikipedia.org/wiki/JPEG | |||
static let jpegMagicNumbers: [UInt8] = [0xFF, 0xD8, 0xFF] | |||
|
|||
// GIF magic numbers https://en.wikipedia.org/wiki/GIF | |||
static let gifMagicNumbers: [UInt8] = [0x47, 0x49, 0x46] |
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.
TIL
@@ -95,7 +95,7 @@ final class SiteMediaCollectionViewController: UIViewController, NSFetchedResult | |||
} | |||
|
|||
private func configureCollectionView() { | |||
collectionView.register(MediaCollectionCell.self, forCellWithReuseIdentifier: Constants.cellID) | |||
collectionView.register(SiteMediaCollectionCell.self, forCellWithReuseIdentifier: Constants.cellID) |
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.
[nit] If you make SiteMediaCollectionCell
conform to Reusable
, you can use defaultReuseID
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.
I didn't know it was there. Thanks – updated!
…ollectionCellViewModel.swift Co-authored-by: Momo Ozawa <[email protected]>
I think I haven't tested this flow: only existing uploads from the web. Let me address that in a separate PR. I put it on the list. |
Just to add to the last comment: there are too many parts of the media that can change after the initial cell display. I want to simplify the way it reloads a bit to fix this issue. I think it'll be best to review it separately. |
@@ -95,7 +95,7 @@ final class SiteMediaCollectionViewController: UIViewController, NSFetchedResult | |||
} | |||
|
|||
private func configureCollectionView() { | |||
collectionView.register(SiteMediaCollectionCell.self, forCellWithReuseIdentifier: Constants.cellID) | |||
collectionView.register(cell: SiteMediaCollectionCell.self) |
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.
Did you mean to do
collectionView.register(SiteMediaCollectionCell.self, forCellWithReuseIdentifier: SiteMediaCollectioinCell.defaultReuseID)
Looks like you're using a extension method defined in Kanvas
func register<T: UICollectionViewCell>(cell cellType: T.Type) {
register(cellType, forCellWithReuseIdentifier: cellType.identifier)
}
This works, because UICollectionReusableView
conforms to Kanvas.Identifiable
. Just wanted to point out that it's not leveraging Reusable
, but Kanvas.Identifiable
instead
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.
Hmm, Kanvas.Identifiable
is nice, but we should probably not rely on it. I want to get this merged before the trunk
gets too far ahead. Let me address it separately together with the filename
fix.
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.
Approving - up to you to decide about my comment above 🙇♀️
Part of #21457
There are multiple changes in this PR, so please bear with me. Once this is merged, the new screens will cover 100% of the original MediaLibraryViewController functionally (and a little bit more). I've been commenting out the re-implement lines as I was working on this project, so this is how I know.
Changes:
I have a couple of more performance improvements in mind, but these will be done later.
To test:
Regression Notes
PR submission checklist:
RELEASE-NOTES.txt
if necessary.UI Changes testing checklist: