Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

A propper way to load images

Đang mở
#335 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
objective-c, react-native
Lĩnh vực
mobile, performance

Hướng nghiên cứu

Bắt đầu bằng việc xem xét tích hợp image-loader của React Native và ví dụ EnrichedImageLoader được cung cấp, bao gồm các đường dẫn xử lý asset cục bộ và header của nó. Xác định cách tích hợp các loader iOS và Android; hoàn thành có nghĩa là các request lặp lại cho cùng một URL hình ảnh được khử trùng lặp mà không làm hỏng asset cục bộ hoặc header của request.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

Currently, if we have multiple images with the same URL, we will fire multiple requests for them. It's okay when we have different small images. But if someone, for some reason, inserts a lot of full hd images with the same url it will take longer to download all of them separately.

Critical problems:

  1. Unnecessary CPU pressure
  2. Additional work for servers
  3. Additional network data usage.
Solution

We should implement/extend react-native's Imageloader or add our own image loader with SDWebImage for ios or GlideLoader for Android.

Here is a simple example with SDWebImageLoader that we currently use in our app:

#import "EnrichedImageLoader.h"
#import <React/RCTUtils.h>

@implementation EnrichedImageLoader
+ (instancetype)shared {
  static EnrichedImageLoader *shared;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    shared = [self new];
    shared.sdManager = [SDWebImageManager sharedManager];
  });
  return shared;
}

- (void)loadImage:(NSURL *)url completion:(void (^)(UIImage *))completion {
  if (!url) {
    completion(nil);
    return;
  }

  if (RCTIsLocalAssetURL(url)) {
    completion(RCTImageFromLocalAssetURL(url));
    return;
  }

  [self.sdManager
      loadImageWithURL:url
               options:SDWebImageHighPriority
              progress:nil
             completed:^(UIImage *_Nullable image, NSData *_Nullable data,
                         NSError *_Nullable error, SDImageCacheType cacheType,
                         BOOL finished, NSURL *_Nullable imageURL) {
               completion(image);
             }];
}

- (void)loadImage:(NSURL *)url
          headers:(NSDictionary<NSString *, NSString *> *)headers
       completion:(void (^)(UIImage *image))completion {
  if (!url) {
    completion(nil);
    return;
  }

  SDWebImageDownloaderRequestModifier *requestModifier =
      [SDWebImageDownloaderRequestModifier
          requestModifierWithBlock:^NSURLRequest *_Nullable(
              NSURLRequest *_Nonnull request) {
            NSMutableURLRequest *modifiedRequest = [request mutableCopy];
            for (NSString *key in headers) {
              [modifiedRequest setValue:headers[key] forHTTPHeaderField:key];
            }
            return modifiedRequest;
          }];

  SDWebImageContext *context =
      @{SDWebImageContextDownloadRequestModifier : requestModifier};

  [self.sdManager
      loadImageWithURL:url
               options:SDWebImageHighPriority
               context:context
              progress:nil
             completed:^(UIImage *_Nullable image, NSData *_Nullable data,
                         NSError *_Nullable error, SDImageCacheType cacheType,
                         BOOL finished, NSURL *_Nullable imageURL) {
               completion(image);
             }];
}

@end

Ngôn ngữ chính
C
Star
1.4k
Fork
67
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của software-mansion/react-native-enriched-html

Tất cả issue của software-mansion/react-native-enriched-html

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.