Skip to content

Commit

Permalink
feat: handle base64 image urls android
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatlV authored Apr 22, 2024
1 parent 7a750a7 commit 57a2fe7
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,19 @@
val drawablePlaceholder: Drawable? = base64Placeholder?.let { getDrawableFromBase64(it, view) }
val failureDrawable: Drawable? = failureImage?.let { getDrawableFromBase64(it, view) }
val thumbHashDrawable = thumbHash?.let { makeThumbHash(view, it) }

// Handle base64 image sources
val imageData = url?.let {
if (it.startsWith("data:image")) {
getDrawableFromBase64(it.substringAfter("base64,"), view)
} else {
it // Use the URL directly
}
}

val imageLoader = view.context.imageLoader
val request = ImageRequest.Builder(view.context)
.data(url)
.data(imageData)
.target(
onStart = { placeholder ->
view.setImageDrawable(placeholder)
Expand Down

0 comments on commit 57a2fe7

Please sign in to comment.