{"id":15055349,"url":"https://github.com/gonzalezreal/networkimage","last_synced_at":"2025-08-25T12:16:07.169Z","repository":{"id":42068654,"uuid":"278608247","full_name":"gonzalezreal/NetworkImage","owner":"gonzalezreal","description":"Asynchronous image loading in SwiftUI","archived":false,"fork":false,"pushed_at":"2024-10-13T09:24:55.000Z","size":4612,"stargazers_count":90,"open_issues_count":1,"forks_count":24,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-22T05:57:46.075Z","etag":null,"topics":["image-downloader","load-image-asynchronously","load-image-url","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/gonzalezreal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-10T10:40:53.000Z","updated_at":"2025-06-15T15:13:09.000Z","dependencies_parsed_at":"2025-01-06T01:06:48.267Z","dependency_job_id":"3b3b042b-1bd1-43cf-afd3-e7d1cbdaee92","html_url":"https://github.com/gonzalezreal/NetworkImage","commit_stats":{"total_commits":69,"total_committers":2,"mean_commits":34.5,"dds":0.02898550724637683,"last_synced_commit":"2849f5323265386e200484b0d0f896e73c3411b9"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/gonzalezreal/NetworkImage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FNetworkImage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FNetworkImage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FNetworkImage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FNetworkImage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonzalezreal","download_url":"https://codeload.github.com/gonzalezreal/NetworkImage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FNetworkImage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272063229,"owners_count":24866676,"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","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["image-downloader","load-image-asynchronously","load-image-url","swift","swiftui"],"created_at":"2024-09-24T21:41:10.241Z","updated_at":"2025-08-25T12:16:07.115Z","avatar_url":"https://github.com/gonzalezreal.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetworkImage\n[![CI](https://github.com/gonzalezreal/NetworkImage/workflows/CI/badge.svg)](https://github.com/gonzalezreal/NetworkImage/actions?query=workflow%3ACI)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fgonzalezreal%2FNetworkImage%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/gonzalezreal/NetworkImage)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fgonzalezreal%2FNetworkImage%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/gonzalezreal/NetworkImage)\n\nNetworkImage is a Swift package that provides image downloading, caching, and displaying for your SwiftUI apps. It leverages the foundation `URLCache` and `NSCache`, providing persistent and in-memory caches.\n\nExplore the [companion demo project](Demo) to discover its capabilities.\n\n## Minimum requirements\n\nYou can use NetworkImage on the following platforms:\n\n* macOS 11.0+\n* iOS 14.0+\n* tvOS 14.0+\n* watchOS 7.0+\n\n## Usage\n\nA network image downloads and displays an image from a given URL; the download is asynchronous,\nand the result is cached both in disk and memory.\n\nThe simplest way of creating a `NetworkImage` view is to pass the image URL to the `init(url:scale:)` initializer.\n\n```swift\nNetworkImage(url: URL(string: \"https://picsum.photos/id/237/300/200\"))\n  .frame(width: 300, height: 200)\n```\n\nTo manipulate the loaded image, use the `content` parameter.\n\n```swift\nNetworkImage(url: URL(string: \"https://picsum.photos/id/237/300/200\")) { image in\n  image\n    .resizable()\n    .scaledToFill()\n    .blur(radius: 4)\n}\n.frame(width: 150, height: 150)\n.clipped()\n```\n\nThe view displays a standard placeholder that fills the available space until the image loads. You\ncan specify a custom placeholder by using the `placeholder` parameter.\n\n```swift\nNetworkImage(url: URL(string: \"https://picsum.photos/id/237/300/200\")) { image in\n  image\n    .resizable()\n    .scaledToFill()\n} placeholder: {\n  ZStack {\n    Color.secondary.opacity(0.25)\n    Image(systemName: \"photo.fill\")\n      .imageScale(.large)\n      .blendMode(.overlay)\n  }\n}\n.frame(width: 150, height: 150)\n.clipped()\n```\n\nTo have more control over the image loading process, use the `init(url:scale:transaction:content)` initializer, which takes a `content` closure that receives a `NetworkImageState` to indicate the state of the loading operation.\n\n```swift\nNetworkImage(url: URL(string: \"https://picsum.photos/id/237/300/200\")) { state in\n  switch state {\n  case .empty:\n    ProgressView()\n  case .success(let image, let idealSize):\n    image\n      .resizable()\n      .scaledToFill()\n  case .failure:\n    Image(systemName: \"photo.fill\")\n      .imageScale(.large)\n      .blendMode(.overlay)\n  }\n}\n.frame(width: 150, height: 150)\n.background(Color.secondary.opacity(0.25))\n.clipped()\n```\n\n## Installation\n### Adding NetworkImage to a Swift package\n\nTo use NetworkImage in a Swift Package Manager project, add the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/gonzalezreal/NetworkImage\", from: \"6.0.0\")\n```\n\nInclude `\"NetworkImage\"` as a dependency for your executable target:\n\n```swift\n.target(name: \"\u003ctarget\u003e\", dependencies: [\n  .product(name: \"NetworkImage\", package: \"NetworkImage\")\n]),\n```\n\nFinally, add `import NetworkImage` to your source code.\n\n### Adding NetworkImage to an Xcode project\n\n1. From the **File** menu, select **Add Packages…**\n1. Enter `https://github.com/gonzalezreal/NetworkImage` into the\n   *Search or Enter Package URL* search field\n1. Link **NetworkImage** to your application target\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fnetworkimage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonzalezreal%2Fnetworkimage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fnetworkimage/lists"}