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

How can we specify URL image scale in WebImage #322

Closed
Kyle-Ye opened this issue Jun 20, 2024 · 6 comments · Fixed by #323
Closed

How can we specify URL image scale in WebImage #322

Kyle-Ye opened this issue Jun 20, 2024 · 6 comments · Fixed by #323
Labels

Comments

@Kyle-Ye
Copy link
Contributor

Kyle-Ye commented Jun 20, 2024

The corresponding SwiftUI.AsyncImage snippets.

let scale = UIScreen.main.scale
let imageName = "\(baseURL)/\(name)_\(Int(scale))x.png"

return AsyncImage(
    url: URL(string: imageName),
    scale: scale
) { image in
    ...
} placeholder: {
    ...
}
@dreampiggy
Copy link
Collaborator

dreampiggy commented Jun 20, 2024

Using .context([.imageScaleFactor] = 2) ?

See SDWebImageContext.h

@dreampiggy
Copy link
Collaborator

Maybe we can polish this API to automatically pass down the scale into the context arg used in SDWebImage Core

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jun 20, 2024

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jun 20, 2024

.context([.imageScale] = 2)

Do you mean using context: [.imageScaleFactor: 2] in current init API?

  1. [SDWebImageContextOption : Any] is using Any so .imageScaleFactor can pass a non-number here.

  2. Another way is appending scale = 1 in all WebImage's init. But what if user set both scale and context: [.imageScaleFactor: 2] at the same time?

@dreampiggy
Copy link
Collaborator

  1. Any is the only way in Objc API...I already have a plan for SDWebImage 6 which use the enum associated object and each key value should be typed.
  2. Follow the same design, if the user provided context contains .imageScale, then it has the highest priority. Since the the scale = 1 is default param

@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Jun 26, 2024

Can we expect a new 3.0.5 or 3.1.0 release?

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

Successfully merging a pull request may close this issue.

2 participants