Skip to content

Commit

Permalink
fix(image): load referer image only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashinch committed Aug 9, 2024
1 parent 26b8bc2 commit f421ae0
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ fun RYAsyncImage(
) {
Image(
painter = rememberAsyncImagePainter(
ImageRequest.Builder(LocalContext.current).addHeader(
"Referer", (data as String).extractDomain() ?: ""
).data(data = data).apply {
model = ImageRequest.Builder(LocalContext.current).apply {
val domain = data.toString().extractDomain()
if (data.toString().extractDomain() != null) {
addHeader("Referer", domain!!)
}
}.data(data = data).apply {
if (placeholder != null) placeholder(placeholder)
if (error != null) error(error)
crossfade(true)
scale(scale)
precision(precision)
size(size)
}.build()
}.build(),
),
contentDescription = contentDescription,
contentScale = contentScale,
Expand Down

0 comments on commit f421ae0

Please sign in to comment.