{"id":28559069,"url":"https://github.com/sdwebimage/sdwebimagelinkplugin","last_synced_at":"2025-06-10T08:36:05.777Z","repository":{"id":62453513,"uuid":"223371636","full_name":"SDWebImage/SDWebImageLinkPlugin","owner":"SDWebImage","description":"A SDWebImage loader plugin, to support load rich link image with LinkPresentation framework","archived":false,"fork":false,"pushed_at":"2020-01-09T07:39:09.000Z","size":3027,"stargazers_count":18,"open_issues_count":5,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-04T03:25:13.095Z","etag":null,"topics":["ios","linkpresentation","macos","sdwebimage"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SDWebImage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-22T09:41:35.000Z","updated_at":"2025-03-09T16:41:43.000Z","dependencies_parsed_at":"2022-11-02T00:01:02.900Z","dependency_job_id":null,"html_url":"https://github.com/SDWebImage/SDWebImageLinkPlugin","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageLinkPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageLinkPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageLinkPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageLinkPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SDWebImage","download_url":"https://codeload.github.com/SDWebImage/SDWebImageLinkPlugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageLinkPlugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039590,"owners_count":22796868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","linkpresentation","macos","sdwebimage"],"created_at":"2025-06-10T08:36:01.501Z","updated_at":"2025-06-10T08:36:05.754Z","avatar_url":"https://github.com/SDWebImage.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SDWebImageLinkPlugin\n\n[![CI Status](https://img.shields.io/travis/SDWebImage/SDWebImageLinkPlugin.svg?style=flat)](https://travis-ci.org/SDWebImage/SDWebImageLinkPlugin)\n[![Version](https://img.shields.io/cocoapods/v/SDWebImageLinkPlugin.svg?style=flat)](https://cocoapods.org/pods/SDWebImageLinkPlugin)\n[![License](https://img.shields.io/cocoapods/l/SDWebImageLinkPlugin.svg?style=flat)](https://cocoapods.org/pods/SDWebImageLinkPlugin)\n[![Platform](https://img.shields.io/cocoapods/p/SDWebImageLinkPlugin.svg?style=flat)](https://cocoapods.org/pods/SDWebImageLinkPlugin)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat)](https://github.com/SDWebImage/SDWebImageLinkPlugin)\n[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager/)\n[![codecov](https://codecov.io/gh/SDWebImage/SDWebImageLinkPlugin/branch/master/graph/badge.svg)](https://codecov.io/gh/SDWebImage/SDWebImageLinkPlugin)\n\n## What's for\nSDWebImageLinkPlugin is a plugin for [SDWebImage](https://github.com/rs/SDWebImage/) framework, which provide the image loading support for rich link URL, by using the [Link Presentation](https://developer.apple.com/documentation/linkpresentation) framework introduced in iOS 13/macOS 10.15.\n\nBy using this plugin, it allows you to use your familiar View Category method from SDWebImage, to load rich link's poster image, with the URL or `LPLinkMetadata`. And make it easy to use `LPLinkView` with cache support.\n\nSee more about Link Presentation in [WWDC 262: Embedding and Sharing Visually Rich Links](https://developer.apple.com/videos/play/wwdc2019/262/)\n\n## Requirements\n\n+ iOS 13+\n+ macOS 10.15+\n+ Xcode 11+\n\n## Installation\n\n#### CocoaPods\n\nSDWebImageLinkPlugin is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'SDWebImageLinkPlugin'\n```\n\n#### Carthage\n\nSDWebImageLinkPlugin is available through [Carthage](https://github.com/Carthage/Carthage).\n\n```\ngithub \"SDWebImage/SDWebImageLinkPlugin\"\n```\n\n#### Swift Package Manager (Xcode 11+)\n\nSDWebImageLinkPlugin is available through [Swift Package Manager](https://swift.org/package-manager).\n\n```swift\nlet package = Package(\n    dependencies: [\n        .package(url: \"https://github.com/SDWebImage/SDWebImageLinkPlugin.git\", from: \"0.1\")\n    ]\n)\n```\n\n## Usage\n\n#### Setup Loader\n\nTo use the LinkPlugin, you should setup the loader firstly. See more here in [Wiki - Loaders Manager](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#loaders-manager)\n\n+ Objective-C\n\n```objective-c\n// Put this code on AppDelegate.m\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n    // Override point for customization after application launch.\n    [SDImageLoadersManager.sharedManager addLoader:SDImageLinkLoader.sharedLoader];\n    SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;\n    return YES;\n}\n```\n\n#### Load Rich Link on UIImageView\n\nThe simple and fast usage, it to use the SDWebImage provided category on `UIImageView`.\n\n+ Objective-C\n\n```objective-c\nNSURL *url = [NSURL URLWithString:@\"https://webkit.org/\"];\nself.imageView = [[UIImageView alloc] init];\nself.imageView.contentMode = UIViewContentModeScaleAspectFit;\n[self.view addSubview:self.imageView];\n[self.imageView sd_setImageWithURL:url completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {\n    if (image \u0026\u0026 [image.sd_extendedObject isKindOfClass:LPLinkMetadata.class]) {\n        NSLog(@\"%@\", @\"UIImageView metadata load success\");\n    }\n}];\n```\n\n#### Load Rich Link on LPLinkView\n\nImportant note on `LPLinkView`: Current iOS 13.0 contains bug that `LPLinkView` may not compatible with TableView/CollectionView cell-reusing. To workaround this issue, you can choose one of these below (one is OK):\n\n1. Do not using cache at all. So, always pass `SDWebImageFromLoaderOnly` to load the metadata from network\n2. Using trick code, create `LPLinkView` with empty `LPLinkMetadata`, or nil URL (important).\n\n+ Objective-C\n\n```objectivec\nNSURL *url = [NSURL URLWithString:@\"https://www.apple.com/iphone/\"];\nself.linkView = [[LPLinkView alloc] initWithURL:nil];\n[self.view addSubview:self.linkView];\n[self.linkView sd_setImageWithURL:url completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {\n    if (image \u0026\u0026 [image.sd_extendedObject isKindOfClass:LPLinkMetadata.class]) {\n        NSLog(@\"%@\", @\"LPLinkView metadata load success\");\n    }\n}];\n```\n\n#### Using LPLinkMetadata\n\nFor some cases, if you have the pre-fetched or pre-created `LPLinkMetadata` object, you can use `SDWebImageContextLinkMetadata` context option to associate it, without extra request to the original link URL. But in most cases, you don't need so, just use the `NSURL` point to the rich link, we query the `LPLinkMetadata` with [LPMetadataProvider](https://developer.apple.com/documentation/linkpresentation/lpmetadataprovider?language=objc).\n\nRemember, if you don't want the double cache (`LPLinkMetadata` archive will contains the image data as well, but not simple image URL), do not sync or cache the metadata from callback's `image.sd_extendedObject` to your own storage using `NSCoding` methods. Let the framework do this thing.\n\n+ Objective-C\n\n```objective-c\n// Decoding a metadata from your serialization solution\nLPLinkMetadata *metadata = [NSKeyedUnarchiver unarchiveObjectWithFile:@\"/path/to/metadata\"];\n// Load image without query metadata again\n[imageView sd_setImageWithURL:metadata.originalURL placeholderImage:nil options:0 context:@{SDWebImageContextLinkMetadata : metadata}];\n```\n\nNote: By default, if the image is cached, we do not send request to query new metadata. If you need to query the metadata as well, consider using SDWebImage's `SDWebImageRefreshCached` option. Or using `SDWebImageFromLoaderOnly` to avoid cache during query.\n\nNote: By default, we prefer to load the image only, which does not generate the image data. This can increase the loading speed. But however, you can also specify to generate the image data by using `SDWebImageContextLinkRequestImageData` context option.\n\n### Backward Deployment\n\nThis framework supports backward deployment on iOS 12-/macOS 10.14- version from v0.3.0. The backward deployment supports Carthage/CocoaPods only (SwiftPM does not support).\n\nFor CocoaPods user, you can skip the platform version validation in Podfile with:\n\n```ruby\nplatform :ios, '13.0' # This does not effect your App Target's deployment target version, just a hint for CocoaPods\n```\n\nFor Carthage user, the built binary framework use weak linking for backward deployment.\n\nPay attention, you should always use the runtime version check to ensure those symbols are available, you should mark all the classes use public API with `API_AVAILABLE` annotation as well. See below:\n\n```objective-c\nif (@available(iOS 13, *)) {\n    SDImageLinkLoader.sharedLoader.timeout = 60;\n}\n\nAPI_AVAILABLE(ios(13.0))\n@interface MyLinkManager : NSObject\n@property (nonatomic) LPLinkMetadata *metadata;\n@property (nonatomic) SDImageLinkLoader *loader;\n@end\n```\n\n## Demo\n\nIf you have some issue about usage, SDWebImageLinkPlugin provide a demo for iOS \u0026\u0026 macOS platform. To run the demo, clone the repo and run the following command.\n\n```bash\ncd Example/\npod install\nopen SDWebImageLinkPlugin.xcworkspace\n```\n\nAfter the Xcode project was opened, click `Run` to build and run the demo.\n\nTips: The iOS demo provide the both of two views' usage. Click `Switch View` to toggle between UIImageView/LPLinkView.\n\n## Screenshot\n\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageLinkPlugin/master/Example/Screenshot/LinkDemo.png\" width=\"300\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageLinkPlugin/master/Example/Screenshot/LinkDemo-macOS.png\" width=\"600\" /\u003e\n\nThese rich link image is from the [Apple site](https://www.apple.com/) and [WebKit site](https://webkit.org/).\n\n## Author\n\nDreamPiggy\n\n## License\n\nSDWebImageLinkPlugin is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimagelinkplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdwebimage%2Fsdwebimagelinkplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimagelinkplugin/lists"}