|
1 | 1 | # ImageSharpCommunity.Providers.Remote |
2 | 2 |
|
| 3 | +[](https://www.nuget.org/packages/ImageSharpCommunity.Providers.Remote/) |
| 4 | +[](https://www.nuget.org/packages/ImageSharpCommunity.Providers.Remote) |
| 5 | +[](https://github.com/skttl/ImageSharp.Community.Providers.Remote/blob/main/LICENSE) |
| 6 | + |
3 | 7 | ImageSharpCommunity.Providers.Remote is a library that provides remote image loading functionality for the ImageSharp.Web library. It allows you to load images from remote URLs and integrate them seamlessly into your ImageSharp-based applications. |
4 | 8 |
|
| 9 | +[A wrapper package for Umbraco, simplyfying the setup is also available!](https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/umbraco-marketplace-readme.md) |
| 10 | + |
5 | 11 | ## Installation |
6 | 12 |
|
7 | 13 | You can install the library via NuGet. |
8 | 14 |
|
9 | | -# [Package Manager](#tab/tabid-1) |
10 | | - |
11 | | -```bash |
12 | | -PM > Install-Package ImageSharpCommunity.Providers.Remote -Version VERSION_NUMBER |
13 | | -``` |
14 | | - |
15 | | -# [.NET CLI](#tab/tabid-2) |
16 | | - |
17 | 15 | ```bash |
18 | 16 | dotnet add package ImageSharpCommunity.Providers.Remote --version VERSION_NUMBER |
19 | 17 | ``` |
20 | 18 |
|
21 | | -# [PackageReference](#tab/tabid-3) |
22 | | - |
23 | | -```xml |
24 | | -<PackageReference Include="ImageSharpCommunity.Providers.Remote" Version="VERSION_NUMBER" /> |
25 | | -``` |
26 | | - |
27 | | -# [Paket CLI](#tab/tabid-4) |
28 | | - |
29 | | -```bash |
30 | | -paket add ImageSharpCommunity.Providers.Remote --version VERSION_NUMBER |
31 | | -``` |
32 | | - |
33 | | -## Usage |
34 | | - |
35 | | -To use the `ImageSharpCommunity.Providers.Remote` library, register the remote image provider in your application's services configuration. This can typically be done in the ConfigureServices method of your Startup class: |
36 | | - |
37 | | -```csharp |
38 | | -public void ConfigureServices(IServiceCollection services) |
39 | | -{ |
40 | | - // Other services configuration... |
41 | | -
|
42 | | - services.AddImageSharp() |
43 | | - .Configure<RemoteImageProviderOptions>(options => |
44 | | - { |
45 | | - options.Settings |
46 | | - .Add(new("/remote") |
47 | | - { |
48 | | - AllowedDomains = new List<string>() { "*" } |
49 | | - }); |
50 | | - }) |
51 | | - .InsertProvider<RemoteImageProvider>(0); |
52 | | -} |
53 | | -``` |
54 | | - |
55 | | -If you are using the default `WebRootProvider`, you need to make sure the `RemoteImageProvider` is inserted before that. Hence why `InsertProvider` is used instead of `AddProvider` in the above example. |
56 | | - |
57 | | -By default, no domains is allowed, so you have to configure your desired `RemoteImageProviderOptions` in order to use this provider. |
58 | | - |
59 | | -## Configuration Options |
60 | | - |
61 | | -The `RemoteImageProviderOptions` class provides the following configuration options: |
62 | | - |
63 | | -- `Settings`: A list of the different allowed sources for images. |
64 | | - |
65 | | -Each setting (`RemoteImageProviderSetting`) provides the following configuration options: |
66 | | - |
67 | | -- `Prefix`: Specified in the constructor, and defines the local path to prefix all remote image requests with. For example, setting this to `/remote` allows requests like `/remote/https://test.com/test.png` to pass through this provider. |
68 | | - |
69 | | -- `RemoteUrlPrefix` (optional): Prefixes the URL on the server. For example, setting this to `https://test.com/` allows requests like `/remote/test.png` to download `https://test.com/test.png`. Note: You still need to allow the specific domain in the `AllowedDomains` setting. |
70 | | - |
71 | | -- `MaxBytes`: Specifies the maximum allowable download size in bytes. By default, it is set to `4194304` bytes (4 MB). |
72 | | - |
73 | | -- `Timeout`: Sets the timeout for a request in milliseconds. By default, it is set to `3000` milliseconds (3 seconds). |
74 | | - |
75 | | -- `UserAgent`: Sets a user agent value for the request. This can be useful for interacting with social networks. By default, it is set to `"ImageSharpRemoteProvider/0.1"`. |
76 | | - |
77 | | -- `HttpClientName`: Sets the name of the HttpClient to use when downloading images. By default, it is set to `"ImageSharpRemoteProvider/HttpClient"`. |
78 | | - |
79 | | -- `AllowedDomains`: Specifies a list of allowable domains to process images from. Images from domains not listed here will be blocked. This is an empty list by default. You can add `*` to allow all domains. |
80 | | - |
81 | | -- `AdditionalOptions`: Allows specifying additional `RemoteImageProviderOptions` instances. This can be useful when you have multiple configurations with different prefixes or other settings. |
82 | | - |
83 | | -Please note that these options provide customization and control over how remote images are loaded and processed. You can adjust these options according to your specific requirements. |
84 | | - |
85 | | -Don't forget to configure these options in your application's services configuration as shown in the Usage section of this README. |
| 19 | +## Documentation |
86 | 20 |
|
87 | | -Please refer to the documentation or the XML comments in the code for more information about each option and its usage. |
| 21 | +- [Setup](https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/docs/setup.md) |
| 22 | +- [Configuration](https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/docs/configuration.md) |
| 23 | +- [Usage](https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/docs/usage.md) |
88 | 24 |
|
89 | 25 | ## Contributing |
90 | 26 |
|
91 | 27 | Contributions to the `ImageSharpCommunity.Providers.Remote` library are welcome! If you encounter any issues or have suggestions for improvements, please feel free to create a new issue or submit a pull request. |
92 | 28 |
|
93 | 29 | ## License |
94 | 30 |
|
95 | | -The `ImageSharpCommunity.Providers.Remote` library is licensed under the [MIT License](https://opensource.org/licenses/MIT). Please see the [LICENSE](LICENSE) file for more details. |
| 31 | +The `ImageSharpCommunity.Providers.Remote` library is licensed under the [MIT License](https://opensource.org/licenses/MIT). Please see the [LICENSE](https://github.com/skttl/ImageSharpCommunity.Providers.Remote/blob/main/LICENSE) file for more details. |
0 commit comments