fix(image): load referer image only when needed

This commit is contained in:
Ash 2024-08-09 15:38:56 +08:00
parent 26b8bc2e14
commit f421ae063a
No known key found for this signature in database
1 changed files with 7 additions and 4 deletions

View File

@ -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,