Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/WordPress/Classes/Utility/Gravatar.swift b/WordPress/Classes/Utility/Gravatar.swift
- index d0b8042d5..34c1f016d 100644
- --- a/WordPress/Classes/Utility/Gravatar.swift
- +++ b/WordPress/Classes/Utility/Gravatar.swift
- @@ -6,6 +6,10 @@ struct Gravatar {
- static let host = "secure.gravatar.com"
- // unknownHash = md5("unknown@gravatar.com")
- static let unknownHash = "ad516503a11cd5ca435acc9bb6523536"
- + // Default size is kind of arbitrary
- + // It's been selected to be larger than the existing used sizes, so it's
- + // easier to catch when we're using the default.
- + static let size = CGFloat(80)
- }
- let canonicalURL: URL
- @@ -73,7 +77,8 @@ extension UIImageView {
- return
- }
- - let size = Int(ceil(frame.width * contentScaleFactor))
- + let pointSize = sizeFromConstraints() ?? Gravatar.Defaults.size
- + let size = Int(ceil(pointSize * contentScaleFactor))
- let url = gravatar.urlWithSize(size)
- self.downloadImage(url,
- @@ -87,4 +92,17 @@ extension UIImageView {
- failure?(error)
- })
- }
- +
- + private func sizeFromConstraints() -> CGFloat? {
- + let widthConstraints = constraints.filter({ constraint in
- + // Ignore NSContentSizeLayoutConstraint that we didn't specify
- + return type(of: constraint) == NSLayoutConstraint.self
- + && constraint.firstItem === self
- + && constraint.firstAttribute == .width
- + })
- + guard widthConstraints.count == 1 else {
- + return nil
- + }
- + return widthConstraints[0].constant
- + }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement