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

Media picker multiplies thumbnail size by UIScreen.scale twice #21197

Closed
kean opened this issue Jul 27, 2023 · 1 comment · Fixed by #21204
Closed

Media picker multiplies thumbnail size by UIScreen.scale twice #21197

kean opened this issue Jul 27, 2023 · 1 comment · Fixed by #21204

Comments

@kean
Copy link
Contributor

kean commented Jul 27, 2023

Expected behavior

  • The requested thumbnail size matches the cell size

Actual behavior

  • The requested thumbnail sizes 4-9 times larger than required

Steps to reproduce the behavior

  • Open media picker

RCA

The media cell requests the size of the thumbnail in pixels (see WPMediaCollectionViewCell.swift:309):

CGFloat scale = [[UIScreen mainScreen] scale];
CGSize requestSize = CGSizeApplyAffineTransform(self.frame.size, CGAffineTransformMakeScale(scale, scale));

When the thumbnail is generated using WPImageURLHelper, it works OK because it accepts the size in pixels.

But when the thumbnail URL is created by PhotonImageURLHelper, it accepts size in points and multiples the size by the screen scale again. In the case of my device, 288x288px becomes 864x864px after being multiplied by the screen scale (x3).

CGFloat scale = [[UIScreen mainScreen] scale];
size.width *= scale;
size.height *= scale;

Example resulting URL: https://i0.wp.com/alextest41234.files.wordpress.com/2023/07/sample-1.gif?quality=80&resize=864,864&ssl=1

@kean
Copy link
Contributor Author

kean commented Jul 27, 2023

WPMediaAsset doesn't specify if the target size is in points or pixels.

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

Successfully merging a pull request may close this issue.

1 participant