-
Notifications
You must be signed in to change notification settings - Fork 643
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
Add support for loading placeholder image from cache via URL #27
Comments
Thanks! I've thought about adding a |
Good points. It sounds like what I'm talking about isn't really a "placeholder", because Coil assumes that placeholders are available straight away, synchronously on the main thread. Have I understood that correctly? Thinking about this overnight, could you do two Something like this:
These requests could technically race, which could be a problem in general with this approach. I'm not sure what the desired behaviour even is when you have two loads for the same target. In this example, you want the first load to proceed, but only until the second load completes. But loading into a RecyclerView you want the opposite, where the first load should be cancelled as soon as the view is reused and the second load starts. |
Ah I see what you mean. This would add a decent chunk of complexity to coroutineScope.launch(Dispatchers.Main.immediate) {
val thumb = async { imageLoader.get(thumbUrl) }
val fullSize = async { imageLoader.get(fullSizeUrl) }
fullSize.invokeOnCompletion { thumb.cancel() }
// There's probably a better way to do this.
val thumbDrawable = try {
thumb.await()
} catch (e: CancellationException) {
null
}
imageView.setDrawable(thumbDrawable)
val fullSizeDrawable = fullSize.await()
imageView.setDrawable(fullSizeDrawable)
} Replace Disclaimer: the above code is completely untested and unoptimized. |
I'd like something similar. I'd like to load image from cache (almost) immediately, but also check the network in the background for change. Our image server supports ETag, and 304 Unchaged response. But because the URL is still the same, Coil will store the image in memory, and never asks the network again, so the user does not see the updated image. So I have the memory cache disabled, but then, when scrolling long list up and down, the images are always blank first and load later, which is distracting. |
Just to check if this is already supported? In glide, I can do as below (placeholder -> initial-fast-load -> full-load) With codes as below
Refer to this article https://medium.com/mobile-app-development-publication/glide-image-loader-the-basic-798db220bb44 Hopes |
Still waiting for this :( |
I would also like to see this feature implemented. I've created a library named AirBrush that uses this feature in Glide, but I'm planning to support Coil due to JetPack Compose. I can hack around it and use |
This feature is the only thing keeping me using Glide for bigger projects. Would love to see a way to do that using Coil |
can anyone suggest any workaround for the coil to achieve the same? |
Here you go. It is used by me in my prod app and no issues/complaints till now. If anyone finds a better solution, please let me know. |
Slight changes to kasem-sm's reply:
|
@0n4li Hey, thanks for improving that code 😊 |
Probably the below code works better. Need to test:
|
Is there any plan to support this feature?
same Here :'( |
any update on this ?? |
does coil support thumbnail size loading as glide does? when i load lot of image in grid in compose, it seems to be delayed compared to scroll action while loading image. |
Any updates on this? |
I tried this and it worked for me in compose:
|
Anyone have an idea on how to do this? Maybe we can throw up an MR to add this support. |
First up, congrats on shipping!
A feature request for consideration. Sometimes an app will show a list of small image thumbnails, which are clickable to open the image full screen. The thumbnails are physically small (in dimension and file size) so the list of thumbnails loads quickly. The full images (loaded from a different URL to the thumbnail) are much bigger, so might take a few seconds to load from the network.
Currently, Coil supports specifying a placeholder
Drawable
using theplaceholder
method. It would be good if that was extended to allow passing in the URL of the thumbnail, which presumably would still be in the memory cache because it was being displayed on the previous screen.The desired effect would look like the image sampling mentioned on the docs website. So the low-res thumbnail would be shown until the full-res image has loaded. The API difference being the first low-res image has come from a different URL, rather than the same one.
I've used "URL" above to keep the wording simple, but I mean all the different "sources" in general that are parameters to the
ImageLoader.load
methods (String
,Uri
,HttpUrl
, etc), or theloadAny
method that uses a Mapper.The text was updated successfully, but these errors were encountered: