Skip to content

Commit 05b9837

Browse files
committed
Update the readme and move the Requirements && Installation to the top, make it more suitable for reading
1 parent 95ffc7c commit 05b9837

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

README.md

+34-33
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,48 @@ SDWebImagePhotosPlugin is a plugin for [SDWebImage](https://github.com/rs/SDWebI
1212

1313
By using this plugin, it allows you to use your familiar View Category method from SDWebImage, to load Photos image with `PHAsset` or `localIdentifier`.
1414

15+
16+
## Requirements
17+
18+
+ iOS 8+
19+
+ macOS 10.13+
20+
+ tvOS 10+
21+
+ Xcode 9+
22+
23+
## Installation
24+
25+
#### CocoaPods
26+
27+
SDWebImagePhotosPlugin is available through [CocoaPods](https://cocoapods.org). To install
28+
it, simply add the following line to your Podfile:
29+
30+
```ruby
31+
pod 'SDWebImagePhotosPlugin'
32+
```
33+
34+
#### Carthage
35+
36+
SDWebImagePhotosPlugin is available through [Carthage](https://github.com/Carthage/Carthage).
37+
38+
Note that because the dependency SDWebImage currently is in beta. You should use `Carthage v0.30.1` or above to support beta [sem-version](https://semver.org/).
39+
40+
```
41+
github "SDWebImage/SDWebImagePhotosPlugin"
42+
```
43+
1544
## Usage
1645
**Important!** To use Photos Library plugin. Firstly you need to register the photos loader to image manager.
1746

1847
There are two ways to register the photos loader. One for temporarily usage (when providing URL is definitely Photos URL but not HTTP URL), and another for global support (don't need any check, support both HTTP URL as well as Photos URL).
1948

2049
#### Use custom manager (temporarily)
21-
You can create custom manager for temporary usage. When you use custom manager, be sure to specify `SDWebImageCustomManager` context option with your custom manager for View Category methods.
50+
You can create custom manager for temporary usage. When you use custom manager, be sure to specify `SDWebImageContextCustomManager` context option with your custom manager for View Category methods.
2251

2352
+ Objective-C
2453

2554
```objectivec
2655
// Assign loader to custom manager
27-
SDWebImageManager *manager = [[SDWebImageManager alloc] initWithCache:SDImageCache.sharedCache loader:SDWebImagePhotosLoader.sharedLoader];
56+
SDWebImageManager *manager = [[SDWebImageManager alloc] initWithCache:SDImageCache.sharedImageCache loader:SDWebImagePhotosLoader.sharedLoader];
2857
```
2958
3059
+ Swift
@@ -35,7 +64,7 @@ let manager = SDWebImageManager(cache: SDImageCache.shared, loader: SDWebImagePh
3564
```
3665

3766
#### Use loaders manager (globally)
38-
You can replace the default manager using [loaders manager](https://github.com/rs/SDWebImage/wiki/Advanced-Usage#loaders-manager) to support both HTTP && Photos URL globally. Put these code just at the application launch time before any SDWebImage loading was triggered.
67+
You can replace the default manager's loader implementation using [loaders manager](https://github.com/rs/SDWebImage/wiki/Advanced-Usage#loaders-manager) to support both HTTP && Photos URL globally. Put these code just at the application launch time (or time just before `SDWebImageManager.sharedManager` initialized).
3968

4069
+ Objective-C
4170

@@ -69,7 +98,7 @@ NSString *identifier;
6998
NSURL *potosURL = [NSURL sd_URLWithAssetLocalIdentifier:identifier];
7099

71100
// Load image (assume using custom manager)
72-
[imageView sd_setImageWithURL:photosURL placeholderImage:nil context:@{SDWebImageCustomManager: manager}];
101+
[imageView sd_setImageWithURL:photosURL placeholderImage:nil context:@{SDWebImageContextCustomManager: manager}];
73102
```
74103
75104
+ Swift
@@ -105,7 +134,7 @@ SDWebImagePhotosLoader.sharedLoader.fetchOptions = fetchOptions;
105134
// allows iCloud Photos Library
106135
PHImageRequestOptions *requestOptions = [PHImageRequestOptions new];
107136
requestOptions.networkAccessAllowed = YES;
108-
[imageView sd_setImageWithURL:photosURL placeholderImage:nil context:@{SDWebImageContextPhotosImageRequestOptions: requestOptions, SDWebImageCustomManager: manager}];
137+
[imageView sd_setImageWithURL:photosURL placeholderImage:nil context:@{SDWebImageContextPhotosImageRequestOptions: requestOptions, SDWebImageContextCustomManager: manager}];
109138
```
110139
111140
+ Swift
@@ -129,34 +158,6 @@ imageView.sd_setImage(with: photosURL, placeholderImage: nil, context:[.photosIm
129158
1. Since Photos Library image is already stored on the device disk. And query speed is fast enough for small resolution image. You can use `SDWebImageContextStoreCacheType` with `SDImageCacheTypeNone` to disable cache storage. And use `SDWebImageFromLoaderOnly` to disable cache query.
130159
2. If you use `PHImageRequestOptionsDeliveryModeOpportunistic` (by default) to load the image, PhotosKit will return a degraded thumb image firstly and again with the full pixel image. When the image is degraded, the loader completion block will set `finished = NO`. But this will not trigger the View Category completion block, only trigger a image refresh (like progressive loading behavior for network image using `SDWebImageProgressiveLoad`)
131160

132-
## Requirements
133-
134-
+ iOS 8+
135-
+ macOS 10.13+
136-
+ tvOS 10+
137-
+ Xcode 9+
138-
139-
## Installation
140-
141-
#### CocoaPods
142-
143-
SDWebImagePhotosPlugin is available through [CocoaPods](https://cocoapods.org). To install
144-
it, simply add the following line to your Podfile:
145-
146-
```ruby
147-
pod 'SDWebImagePhotosPlugin'
148-
```
149-
150-
#### Carthage
151-
152-
SDWebImagePhotosPlugin is available through [Carthage](https://github.com/Carthage/Carthage).
153-
154-
Note that because the dependency SDWebImage currently is in beta. You should use `Carthage v0.30.1` or above to support beta [sem-version](https://semver.org/).
155-
156-
```
157-
github "SDWebImage/SDWebImagePhotosPlugin"
158-
```
159-
160161
## Demo
161162

162163
If you have some issue about usage, SDWebImagePhotosPlugin provide a demo for iOS && macOS platform. To run the demo, clone the repo and run the following command.

0 commit comments

Comments
 (0)