0

So I use this test endpoint for my sample app https://jsonplaceholder.typicode.com/albums/1/photos

For example Glide tries to load this image https://via.placeholder.com/150/24f355 but fails with

com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: 410 Caused by: java.io.FileNotFoundException: https://via.placeholder.com/150/24f355

@BindingAdapter("imageFromUrl")
@JvmStatic
fun loadImageFromUrl(imageView: ImageView, url: String?) {
    url?.let { loadImage(imageView, Glide.with(imageView.context).load(it)) }
}

private fun loadImage(imageView: ImageView, request: RequestBuilder<Drawable>) {
    request
        //.placeholder(R.drawable.PLACEHOLDER)
        //.error(R.drawable.ERROR)
        .centerCrop()
        .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
        .into(imageView)
}

If I add ".jpg" to url string (https://via.placeholder.com/150/24f355.jpg) then it works fine

Ryan M
  • 18,333
  • 31
  • 67
  • 74
user924
  • 8,146
  • 7
  • 57
  • 139
  • 2
    Does this answer your question? [Use Glide to load images from URL but without extensions](https://stackoverflow.com/questions/56376339/use-glide-to-load-images-from-url-but-without-extensions) – Anuj Sharma Sep 15 '21 at 14:06
  • @AnujSharma well I don't really get it cause I'm not server developer – user924 Sep 15 '21 at 14:26

1 Answers1

-1

From placeholder documentation:

Image format is optional – the default is a .GIF. You can use the following image file extensions… .GIF .JPG .JPEG .PNG

I think you are trying to load a .gif , so you could try this answer: Show GIF file with Glide (image loading and caching library)

That's why when you specify a extension it works fine, but that alternative is also valid according to the website.

Adding an image file extension will render the image in the correct format.

javdromero
  • 1,850
  • 2
  • 11
  • 19