SDWebImage / SDWebImageLinkPlugin

A SDWebImage loader plugin, to support load rich link image with LinkPresentation framework
MIT License
17 stars 2 forks source link

Add a option to disable video resource to fetch #12

Closed dreampiggy closed 4 years ago

dreampiggy commented 4 years ago

This close #10

inPhilly commented 4 years ago

I'm not sure if this comment should be here or in the original issue, so I am putting it in both; if it is wrong to put it here, let me know and I will delete it.

I'm not sure if it matters, but in this case, which is right (or preferable), #1 or #2?

1

SDWebImageManager *manager = [[SDWebImageManager alloc] initWithCache:SDImageCache.sharedImageCache loader:SDImageLinkLoader.sharedLoader];
SDImageLinkLoader.sharedLoader.shouldfetchVideoResources = NO;
[_linkView sd_setImageWithURL:[NSURL URLWithString:linkURLString] placeholderImage:nil options:0 context:@{SDWebImageContextCustomManager:manager}];

2

SDImageLinkLoader.sharedLoader.shouldfetchVideoResources = NO;
SDWebImageManager *manager = [[SDWebImageManager alloc] initWithCache:SDImageCache.sharedImageCache loader:SDImageLinkLoader.sharedLoader];
[_linkView sd_setImageWithURL:[NSURL URLWithString:linkURLString] placeholderImage:nil options:0 context:@{SDWebImageContextCustomManager:manager}];
dreampiggy commented 4 years ago

Both are OK. This property shouldfetchVideoResources is used on demand, which means each time it will check current status.

And actually, if you just want a global control, not per-image-request control, you can set this property once.

// AppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    //....
    SDImageLinkLoader.sharedLoader.shouldfetchVideoResources = NO;
}

If you need to control each image request whether to allows video or not. This design may cause problem . We need to switch this video control into a context option. PR is needed.