kean / Nuke

Image loading system
https://kean.blog/nuke
MIT License
8.17k stars 529 forks source link

Placeholder weird behaviour #554

Closed cpd closed 2 years ago

cpd commented 2 years ago

Hi, I'm trying to switch to Nuke from Kingfisher, I found that passing invalid url to request parameter in Nuke.loadImage results in empty UIImageView (placeholder that's passed in ImageLoadingOptions is not used) It's weird because that's what placeholder should do (be displayed if there's problems with loading actual image)

Kingfisher shows placeholder if passed url is broken which looks 'the correct way', accepting optional url and not displaying placeholder if url is nil doesn't look the obvious behaviour, did I miss something?

kean commented 2 years ago

Hi,

Placeholder is displayed while the image is loading. If the download fails, a failureImage is displayed. You can find more info in the documentation.

It's designed very similarly to the newest Apple's AsyncImage API where placeholder fills the space during loading:

Until the image loads, the view displays a standard placeholder that fills the available space. After the load completes successfully, the view updates to display the image. In the example above, the icon is smaller than the frame, and so appears smaller than the placeholder.

If you think it's something that's worth adding to the guide designed to help switching from Kingfisher, PRs are welcome.

cpd commented 2 years ago

Placeholder is displayed while the image is loading. If the download fails, a failureImage is displayed. You can find more info in the documentation.

Somehow I missed that.. thanks, that's what I was looking for

It's designed very similarly to the newest Apple's AsyncImage

while the 'placeholder' is used in same way the AsyncImage api expects a closure that returns View so you can return a progress view which makes more sense than just an image, anyway, failureImage looks ok for my use cases, thanks for clarifications.

kean commented 2 years ago

LazyImageView from NukeUI has a placeholderView option. I'm focusing on this framework for providing UI-related features.