SDWebImage / SDWebImageLinkPlugin

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

Option to suppress Video data from LPLinkMetadata? #10

Closed inPhilly closed 4 years ago

inPhilly commented 4 years ago

In SDImageLinkLoader, in the returned LPLinkMetadata from startFetchingMetadataForURL, I have to manually set:

metadata.remoteVideoURL = nil; metadata.videoProvider = nil;

before the line:

url.sd_linkMetadata = metadata;

These means that I can't use Carthage at this time, because I need to manually change the file. Is it possible to add the option to suppress all video data from the LPLinkMetadata into the plugin options?

dreampiggy commented 4 years ago

I don't know what you means anything related to Carthage.

You should better try 0.2.0+ version, which does not have any sd_linkMetadata API.

The coorespond API may be the SDWebImageContextLinkMetadata context option

dreampiggy commented 4 years ago

If you still can not build Carthage, maybe you can just drag the entire Xcode project into your own project, let it become's the sub-project. Then add the Linked Library option in Xcode.

See the similiar thing in https://github.com/SDWebImage/SDWebImage/wiki/Installation-Guide#manual-installation-guide

dreampiggy commented 4 years ago

And, the videoURL is kept. You can check our demo to see the final fetched LPLinkMrtadata. Only the provider is not synced, but you don’t need that right ? Because SDWebImage’s completion block already provide one UIImage instance

inPhilly commented 4 years ago

Okay, sorry I wasn't more clear. I can install via Carthage successfully now. That issue is fixed for me (except for the App Extension, which throws an error saying the framework is unsafe for App Extensions - I will be posting that issue shortly).

I was saying that because I need to manually change the files, I had to manually install SDWebImageLinkPlugin, instead of installing it through Carthage. But, this does cause other issues, so I would like to use Carthage and the most recent version. But this limits me from modifying the files in the framework.

I am not sure exactly what you are saying to do. I simply want to remove remoteVideoURL and videoProvider in every case (if one or both exists). I do not want to display video in the LPLinkView, and I don't want to store those values in the metadata cache. Can I set this as an option, somewhere, without modifying the files in the framework? If so, how?

Thanks again for all of your work on this. I am very excited to be able to use it.

dreampiggy commented 4 years ago

I do not want to display video in the LPLinkView, and I don't want to store those values in the metadata cache.

This sounds like a feature request, I'll provide a PR to support this via a new context option, or a new property inside SDImageLinkLoader, like fetchImageMetaOnly

dreampiggy commented 4 years ago

@inPhilly Try to use v0.2.4 version and set

SDImageLinkLoader.sharedLoader.shouldfetchVideoResources = NO;

inPhilly commented 4 years ago

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}];