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

View File

@ -35,16 +35,19 @@ fun RYAsyncImage(
) { ) {
Image( Image(
painter = rememberAsyncImagePainter( painter = rememberAsyncImagePainter(
ImageRequest.Builder(LocalContext.current).addHeader( model = ImageRequest.Builder(LocalContext.current).apply {
"Referer", (data as String).extractDomain() ?: "" val domain = data.toString().extractDomain()
).data(data = data).apply { if (data.toString().extractDomain() != null) {
addHeader("Referer", domain!!)
}
}.data(data = data).apply {
if (placeholder != null) placeholder(placeholder) if (placeholder != null) placeholder(placeholder)
if (error != null) error(error) if (error != null) error(error)
crossfade(true) crossfade(true)
scale(scale) scale(scale)
precision(precision) precision(precision)
size(size) size(size)
}.build() }.build(),
), ),
contentDescription = contentDescription, contentDescription = contentDescription,
contentScale = contentScale, contentScale = contentScale,