AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

Overview

URLImage

Follow me on Twitter

URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it locally, both in memory and on disk, for you.

Using URLImage is dead simple:

URLImage(url: url) { image in
    image
        .resizable()
        .aspectRatio(contentMode: .fit)
}

Take a look at some examples in the demo app.

Table of Contents

Features

  • SwiftUI image view for remote images;
  • Local image cache;
  • Fully customizable including placeholder, progress indication, error, and the image view;
  • Control over various download aspects for better performance.

Installation

URLImage can be installed using Swift Package Manager.

  1. In Xcode open File/Swift Packages/Add Package Dependency... menu.

  2. Copy and paste the package URL:

https://github.com/dmytro-anokhin/url-image

For more details refer to Adding Package Dependencies to Your App documentation.

Usage

You can create URLImage with URL and a ViewBuilder to display downloaded image.

import URLImage // Import the package module

let url: URL = //...

URLImage(url) { image in
    image
        .resizable()
        .aspectRatio(contentMode: .fit)
}

Note: first argument of the URLImage initialiser is of URL type, if you have a String you must first create a URL object.

View Customization

URLImage view manages and transitions between 4 download states:

  • Empty state, when download has not started yet, or there is nothing to display;
  • In Progress state to indicate download process;
  • Failure state in case there is an error;
  • Content to display the image.

Each of this states has a separate view. You can customize one or more using ViewBuilder arguments.

URLImage(item.imageURL) {
    // This view is displayed before download starts
    EmptyView()
} inProgress: { progress in
    // Display progress
    Text("Loading...")
} failure: { error, retry in
    // Display error and retry button
    VStack {
        Text(error.localizedDescription)
        Button("Retry", action: retry)
    }
} content: { image in
    // Downloaded image
    image
        .resizable()
        .aspectRatio(contentMode: .fit)
}

Options

URLImage allows to control certain aspects using URLImageOptions structure. Things like whenever to download image or use cached, when to start and cancel download, how to configure network request, what is the maximum pixel size, etc.

URLImageOptions is the environment value and can be set using \.urlImageOptions key path.

URLImage(url) { image in
    image
        .resizable()
        .aspectRatio(contentMode: .fit)
}
.environment(\.urlImageOptions, URLImageOptions(
    maxPixelSize: CGSize(width: 600.0, height: 600.0)
))

Setting URLImageOptions in the environment value allows to set options for a whole or a part of your views hierarchy.

@main
struct MyApp: App {

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.urlImageOptions, URLImageOptions(
                    maxPixelSize: CGSize(width: 600.0, height: 600.0)
                ))
        }
    }
}

Image Information

You can use ImageInfo structure if you need information about an image, like actual size, or access the underlying CGImage object. ImageInfo is an argument of content view builder closure.

URLImage(item.imageURL) { image, info in
    if info.size.width < 1024.0 {
        image
            .resizable()
            .aspectRatio(contentMode: .fit)
    } else {
        image
            .resizable()
            .aspectRatio(contentMode: .fill)
    }
}

Zoom In

If you want to add ability to scale the image consider checking AdvancedScrollView package.

import AdvancedScrollView
import URLImage

URLImage(url) { image in
    AdvancedScrollView(magnificationRange: 1.0...4.0) { _ in
        image
    }
}

Cache

URLImage can also cache images to lower network bandwith or for offline use.

By default, URLImage uses protocol cache policy, i.e. Cache-Control HTTP header and URLCache. This corresponds to how images work on web and requires network connection.

Alternatively, if you want to view images offline, you must configure the file store. When configured, URLImage will no longer use protocol cache policy, and instead follow URLImageOptions.FetchPolicy setting.

import URLImage
import URLImageStore

@main
struct MyApp: App {

    var body: some Scene {

        let urlImageService = URLImageService(fileStore: URLImageFileStore(),
                                          inMemoryStore: URLImageInMemoryStore())

        return WindowGroup {
            FeedListView()
                .environment(\.urlImageService, urlImageService)
        }
    }
}

Make sure to include URLImageStore library under "Frameworks, Libraries,and Embedded Content" of your target settings.

Store Use Cases

You may ask when to use protocol or custom cache. URLImage designed to serve two use cases:

Use protocol cache policy when an app can only work connected to the internet. Ecommerce apps, such as shopping, travel, event reservation apps, etc., work like this. Following protocol cache policy you can be sure that images are cached in a way that your CDN defines, can still be accessed quickly, and don't take unnecessary space on user devices.

Configure URLImageStore for content that needs to be accessed offline or downloaded in background. This can be a reader app, you probably want to download articles before user opens them, maybe while the app is in the background. This content should stay for a considerably long period of time.

Advanced

Start Loading

URLImage starts loading when the image view is rendered. In some cases (like with List) you may want to start loading when view appears and cancel when it disappears. You can customize this using URLImageOptions.LoadOptions options. You can combine multiple to achieve behaviour that fits your UI best.

List(/* ... */) {
    // ...
}
    .environment(\.urlImageOptions, URLImageOptions(loadOptions: [ .loadOnAppear, .cancelOnDisappear ]))

Note: versions prior to 3.1 start loading on appearance and cancel when view disappears. Version 3.1 starts loading when the view renders. This is because onAppear and onDisappear callbacks are quite unpredictable without context.

Make Your Own URLImage

Alternatively you can make your own URLImage to customize appearance and behaviour for your needs.

struct MyURLImage: View {

    @ObservedObject private var remoteImage: RemoteImage

    init(service: URLImageService, url: URL) {
        remoteImage = service.makeRemoteImage(url: url, identifier: nil, options: URLImageOptions())
    }

    var body: some View {
        ZStack {
            switch remoteImage.loadingState {
                case .success(let value):
                    value.image

                default:
                    EmptyView()
            }
        }
        .onAppear {
            remoteImage.load()
        }
    }
}

You can access service environment value from enclosing view: @Environment(\.urlImageService) var service: URLImageService.

Fetching an Image

You may want to download an image without a view. This is possible using the RemoteImagePublisher object. The RemoteImagePublisher can cache images for future use by the URLImage view.

Download an image as CGImage and ignore any errors:

cancellable = URLImageService.shared.remoteImagePublisher(url)
    .tryMap { $0.cgImage }
    .catch { _ in
        Just(nil)
    }
    .sink { image in
        // image is CGImage or nil
    }

Download multiple images as an array of [CGImage?]:

let publishers = urls.map { URLImageService.shared.remoteImagePublisher($0) }

cancellable = Publishers.MergeMany(publishers)
    .tryMap { $0.cgImage }
    .catch { _ in
        Just(nil)
    }
    .collect()
    .sink { images in
        // images is [CGImage?]
    }

When downloading image using the RemoteImagePublisher object all options apply as they do for the URLImage object. Be default downloaded image will be cached on the disk. This can speedup displaying images on later stage of your app. Also, this is currently the only supported way to display images in iOS 14 widgets.

Download an Image in iOS 14 Widget

Unfortunately views in WidgetKit can not run asynchronous operations: https://developer.apple.com/forums/thread/652581. The recommended way is to load your content, including images, in TimelineProvider.

You can still use URLImage for this. The idea is that you load image in TimelineProvider using the RemoteImagePublisher object, and display it in the URLImage view.

Migration Notes v2 to v3

  • URLImage initialiser now omits an argument label for the first parameter, making URLImage(url: url) just URLImage(url).
  • URLImage initialiser now uses ViewBuilder attribute for closures that construct views.
  • URLImageOptions now passed in the environment, instead of as an argument. Custom identifier can still be passed as an argument of URLImage.
  • By default URLImage uses protocol cache policy and URLCache. This won't store images for offline usage. You can configure the file store as described in cache section.
  • Swift Package Manager is now the only officially supported dependency manager.

Common Issues

Image reloads when view reloads

This is a common issue if you use URLImage alongside TextField or another control that updates a state that triggers view update. Because URLImage is asynchronous and initially empty, it will reset to empty state before displaying downloaded image. To avoid this, setup URLImageInMemoryStore somewhere in your App.

import SwiftUI
import URLImage
import URLImageStore

@main
struct MyApp: App {
    var body: some Scene {
        let urlImageService = URLImageService(fileStore: nil, inMemoryStore: URLImageInMemoryStore())

        return WindowGroup {
            ContentView()
                .environment(\.urlImageService, urlImageService)
        }
    }
}

Note: you can reset cached image using removeImageWithURL, removeImageWithIdentifier, or removeAllImages methods of URLImageInMemoryStore.

Image in navigation/toolbar displayed as single color rectangle

This is not a bug. Navigation/toolbar uses .renderingMode(.template) to display images as templates (renders all non-transparent pixels as the foreground color). The way to reset it is to specify .renderingMode(.original):

URLImage(url) { image in
    image.renderingMode(.original)
}

Reporting a Bug

Use GitHub issues to report a bug. Include this information when possible:

Summary and/or background; OS and what device you are using; Version of URLImage library; What you expected would happen; What actually happens; Additional information: Screenshots or video demonstrating a bug; Crash log; Sample code, try isolating it so it compiles without dependancies; Test data: if you use public resource provide URLs of the images.

Please make sure there is a reproducible scenario. Ideally provide a sample code. And if you submit a sample code - make sure it compiles ;)

Requesting a Feature

Use GitHub issues to request a feature.

Contributing

Contributions are welcome. Please create a GitHub issue before submitting a pull request to plan and discuss implementation.

Comments
  • iOS 14 Compatibility

    iOS 14 Compatibility

    Current version of the package is compatible with iOS 14 beta, build 18A5301v.

    For any bugs you encounter comment out in this issue and I will make fix them. Note that iOS 14 is in early beta and there is a high chance to encounter a bug in SwiftUI itself.

    Please provide the sample code so I can tackle bugs quicker.

    enhancement iOS 14 
    opened by dmytro-anokhin 32
  • Download doesn't start for some PNG images

    Download doesn't start for some PNG images

    Summary and/or background In some instances, when displaying a PNG image, the download doesn't start. I have verified this by using the empty argument. Unfortunately, I cannot create a reproduction view, because every time I do, it works. But in my app, when trying to display a PNG image, the download does not start. I know not being able to provide a reproduction is unfortunate, but is there anything you can think of that could cause this?

    OS and what device you are using

    • OS: macOS 10.15.7
    • Simulator iPhone 12 Pro iOS 14.1

    Version of URLImage library The version of the library where the bug happens.

    • [ ] The bug is reproducible in the latest version.

    What you expected would happen The PNG image is displayed in my app.

    What actually happens The image is not displayed, instead the result of the empty argument is.

    Sample code Sorry about this, I can't seem to isolate the problem.

    Test data https://nightspot.app/api/München/P1/logo.png

    Additional information:

    • image
    bug cannot reproduce 
    opened by CollinAlpert 9
  • Roadmap to v2.0

    Roadmap to v2.0

    Motivation

    URLImage has grown from a small library to a functional package. Since original release after WWDC 2019, features like incremental loading, flexible image cache, filters, were implemented. Besides that, a number of feature requests implemented, bugs fixed, SwiftUI learned, and pitfalls discovered. I'm grateful everyone who helped me to investigate bugs and created feature request. This really pushed the package forward.

    With features comes complexity. My intention was to keep URLImage lightweight, but currently this is not the case. With small changes here and there the code became hard modify.

    Development is iterative process and now is time for big refactoring iteration: v2.0.

    Goals

    URLImage was developed with performance in mind. Files are downloaded directly on disk to reduce memory footprint. Image decoding and processing done in background threads to minimize UI thread utilization. Download tasks are reused, even when there are multiple views that initiate download, to reduce network traffic consumption.

    My intention is to keep this fundamental features.

    The focus for v2 is on architecture and flexibility. This will open next possibilities:

    • Clear data flow (download, caching, decoding, and processing);
    • Download files without UI;
    • Unit tests for individual components.

    Process

    v2.0 will be built from ground up, using all the good parts from v1.0. This will allow me to rethink architecture and structure of the package.

    Package will be split into local dependencies managed by SPM. There will be code breaking API changes and number of features will be initially reduced.

    Progress can be tracked in version_2 branch.

    There won't be new development for current version. I will of course fix critical bugs if any. After releasing v2.0, previous version will be deprecated. I will keep the current version so you will be able to use it.

    Timeline

    When it's ready 🙂 I work on this project in my spare time and it is currently my top priority. So should be soon (-ish).

    enhancement in progress v2.0 
    opened by dmytro-anokhin 9
  • Improve performance on large sets of images

    Improve performance on large sets of images

    I have an iPad app with 3 lists, 2 horizontally scrolling, and 1 vertical scrolling grid. The total number of images across these three lists totals about 200.

    It seems this is causing a serious slowdown when the app is launched, whereby the screen is unresponsive for about 5-6 seconds.

    Replacing the URLImages with the same Image that I use as a placeholder shows none of the same issues.

    I've set increasing delays on the images the further down they are in the list, so that no more than 8 images are loaded per second, but this hasn't changed the behaviour at all

    enhancement 
    opened by JesalR 9
  • Crash on Xcode 11 beta 5

    Crash on Xcode 11 beta 5

    Hi,

    Was working fine on beta 4. This morning with beta 5 my view using UrlImage crashes. I realized it never happens the first time you open the view, only the second time.

    The error message is:

    *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]. Layer: <CALayer:0x28350fd40; position = CGPoint (15 3.01956e+307); bounds = CGRect (0 0; 128 0); delegate = <SwiftUI._UIShapeHitTestingView: 0x123d2fc00; frame = (15 3.01956e+307; 128 0); anchorPoint = (0, 0); autoresizesSubviews = NO; layer = <CALayer: 0x28350fd40>>; allowsGroupOpacity = YES; _swiftUI_displayListID = 87; cornerRadius = 38.5; borderColor = (null); backgroundColor = <CGColor 0x28111bc60> [<CGColorSpace 0x28112d0e0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 0 0 0 1 ); anchorPoint = CGPoint (0 0)>'
    *** First throw call stack:
    (0x1a104edf8 0x1a0d780a4 0x1a0f44b80 0x1a7a45ed8 0x1a7a36fc0 0x1d6e1102c 0x1d7082f80 0x1d70814e0 0x1d7080ee0 0x1d6c7ca7c 0x1d6e4de50 0x1d6e4db80 0x1d6e4d7d4 0x1d6e4d64c 0x1d6bd8bd4 0x1d6feb048 0x1d6fe8b44 0x1d7157a20 0x1d7157a4c 0x1a549e2cc 0x1a7a3c694 0x1a7a40ec4 0x1a7a4c8b8 0x1a7997c70 0x1a79c1bd8 0x1a79c25cc 0x1a0fcc140 0x1a0fc702c 0x1a0fc75f8 0x1a0fc6db4 0x1ab2d6328 0x1a501de94 0x104f07b44 0x1a0e52424)
    libc++abi.dylib: terminating with uncaught exception of type NSException
    

    Any ideas?

    wontfix 
    opened by benclanet 9
  • Loaded image diverts back to placeholder on sheet presentation

    Loaded image diverts back to placeholder on sheet presentation

    I have a list of rows, in each row there is a URLImage() and some text.

     HStack{
                VStack(alignment: .leading){
                    Text(self.location.mapItem.name!)
                        .bold()
                        .lineLimit(3)
                    Text(self.location.address).color(.secondary).font(.system(size: 13)).lineLimit(2)
                    Text("Rating: \(self.location.rating)").color(.secondary).font(.system(size: 13))
                    }
                Spacer()
                URLImage(location.imageReference)
                    .frame(minWidth: 80, maxWidth: 80, minHeight: 80, maxHeight: 80)
                    .clipped()
                    .cornerRadius(10)
                    .aspectRatio(contentMode: .fit)
                    .frame(width: 100)
                }.padding(.all).presentation(showingSheet ? sheet : nil).tapAction {
                    self.showingSheet = true
            }
    

    Whenever I tap the cell row, the Image which has been loaded the disappears and the placeholder appears.

    bug 
    opened by nikokent 9
  • Remove image cache with completion block

    Remove image cache with completion block

    Is your feature request related to a problem? Please describe. I'm trying to remove an image that is cached but since the progress happens in a background thread I don't know when it has completed.

    Describe the solution you'd like It would be nice to have a completion block called when the process finish so I can refresh the UI and be sure that the image will be downloaded from network and the cache will be gone.

    Describe alternatives you've considered Right now I'm using a DispatchQueue.main.asyncAfter of half a second before updating the UI to be sure the cached image is completely removed.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement in progress 
    opened by pballart 8
  • LazyVStack containing a list of images is choppy when scrolling.

    LazyVStack containing a list of images is choppy when scrolling.

    Summary and/or background When using a LazyVStack contained in ScrollView to render lazily views (for example when working with large amount of data) and these views contain an URLImage, scrolling is very choppy.

    OS and what device you are using

    • OS: iOS 14 beta, Xcode 12 Beta 6
    • iPhone X

    Version of URLImage library 0.9.19

    • [ x] The bug is reproducible in the latest version.

    What you expected would happen The scroll should be smooth.

    What actually happens LazyVStack load a view when it needs to be displayed; this means that during scrolling a lot of views are created and therefore URLImage are created too (so they'll load the image). I'm not sure how Apple implemented LazyVStack, so I don't know if a view is reused (like in UICollectionView) or every time a view is created.

    If I change the code to use a simple VStack, everything works good (I assume because all views are loaded just once).

    Sample code

    Body of the main scene

    ScrollView(showsIndicators: false) {
                        LazyVStack {
                            ForEach(viewModel.players) { player in
                                PlayerRowView(player: player) {
                                    viewModel.playerDidTap(player)
                                }
                            }
                        }
                        .padding(.horizontal)
                    }
    

    Body of PlayerRowView

    Button(action: tapAction) {
                HStack(spacing: 16 ) {
                    AvatarView(path: player.playerImg)
                        .frame(width: 70, height: 70)
                    VStack(alignment: .leading) {
                        Text(player.name)
                            .bold()
                        HStack {
                            flag(for: player.clubImg)
                            flag(for: player.leagueImg)
                            flag(for: player.nationImg)
                        }
                    }
                    Spacer()
                    VStack(alignment: .trailing, spacing: 8) {
                        Text(player.version ?? "")
                            .font(.subheadline)
                            .bold()
                            .lineLimit(1)
                            .minimumScaleFactor(0.3)
                            .foregroundColor(.secondary)
                        Text(String(player.rating ?? 0))
                            .font(.title2)
                            .bold()
                    }
                }
                .foregroundColor(.primary)
                .padding()
                .background(Color.backgroundSecondary)
                .cornerRadius(16)
            }
    
        private func flag(for path: String?) -> some View {
            URLImage(path: path) { $0.image.resizable() }
                .aspectRatio(contentMode: .fit)
                .frame(width: 20, height: 20)
        }
    
    struct AvatarView: View {
    
        let path: String?
    
        var body: some View {
            ZStack {
                Circle()
                    .foregroundColor(.clear)
                    .layoutPriority(1)
                URLImage(path: path) { $0.image.resizable() }
                    .aspectRatio(contentMode: .fit)
            }
            .aspectRatio(contentMode: .fit)
            .background(LinearGradient(gradient: Gradient(colors: [.green, .blue]),
                                       startPoint: .bottomLeading,
                                       endPoint: .trailing).opacity(1))
            .clipShape(Circle())
        }
    
    }
    

    Additional information: Video to compare VStack vs LazyVStack usages. Videos.zip

    bug fixed 
    opened by rico-crescenzio-distilled 8
  • Image is rotated from portrait to landscape?

    Image is rotated from portrait to landscape?

    Summary and/or background When the image is displayed in the view it is rotated and then displayed

    OS and what device you are using

    • OS: iOS
    • Device or simulator: Occurs on both device and simulator ios 13

    Version of URLImage library The version of the library where the bug happens: 0.9.13

    • The bug is reproducible in the latest version.

    What you expected would happen The image would display in portrait mode

    What actually happens The image is rotated to landscape

    Sample code The sample code helps a lot. Try isolating the sample code so it compiles without dependancies.

        var body: some View {
            Group {
                VStack(alignment: .leading) {
                    URLImage(
                        url,
                        placeholder: { _ in
                            Text("yo")
                        }
                    ) { proxy in
                        proxy.image
                            .resizable()
                            .aspectRatio(contentMode: .fit)
                    }
                }
            }
        }
    

    Test data The image in question: https://firebasestorage.googleapis.com/v0/b/ms-chanandler-bong.appspot.com/o/flaneur%2Fplaces%2FRib%2F2020-04-09-qzo7Op?alt=media&token=cfc424dc-4f46-4c56-88d0-bb5463f6f172

    Additional information:

    It looks like this:

    image

    bug 
    opened by aliak00 8
  • Image size issue when no .frame() set

    Image size issue when no .frame() set

    When no frame modifier is set, once the image is loaded, it will render with the same size as the placeholder (which is an icon when nothing is set). Changing the device orientation will trigger a re-layout and the image will render as expected.

    See code sample below:

    var body: some View {
            
            GeometryReader { geometry in
                NavigationView {
                    ScrollView(.vertical, showsIndicators: true) {
                        VStack {
                            ...
                            HStack {
                                URLImage(URL(string: "https://i.pinimg.com/originals/f2/37/0b/f2370b7313d49bbb6959f85df2a851c4.jpg")!)
                                    .resizable()
                                    .aspectRatio(contentMode: .fit)
                                    .clipShape(RoundedRectangle(cornerRadius: 20) )
                                Spacer().frame(width: 50)
                            }
                            ...
                        }
                    }                
                }.navigationViewStyle(StackNavigationViewStyle()) 
            }
        }
    
    opened by francksyren 8
  • 2.1.0 - changing initial image url shows placeholder until the view's visibility is toggled

    2.1.0 - changing initial image url shows placeholder until the view's visibility is toggled

    Summary and/or background Changing initial image url requires a view visibility toggle before the newly fetched image appears.

    OS and what device you are using

    • OS: iOS
    • All Simulators

    Version of URLImage library

    • [x] The bug is reproducible in the latest version.

    What you expected would happen When you change the initial url, the new image should be shown after it is fetched.

    What actually happens The placeholder is shown even though the image has been retrieved. You must manually hide and show the view before the new image will appear.

    Sample code Here's a quick sample which reproduces the issue:

    
    import SwiftUI
    import URLImage
    
    struct ContentView: View {
    
        static let fishURL = URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Redear_sunfish_FWS_1.jpg/277px-Redear_sunfish_FWS_1.jpg")!
        static let horseURL = URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/Zaniskari_Horse_in_Ladhak%2C_Jammu_and_kashmir.jpg/320px-Zaniskari_Horse_in_Ladhak%2C_Jammu_and_kashmir.jpg")!
        
        @State var url = fishURL
        @State var show = true
    
        private let placeholder: some View = Image(systemName: "photo")
            .foregroundColor(.white)
    
        var body: some View {
            Text("If you tap 'Show horse' below it shows just the placeholder. If you try to toggle back and forth between the fish and horse the placeholder is always shown for the horse even though the image has been retrieved.")
                .padding()
            
            if show {
                URLImage(url: url,
                         empty: {
                            placeholder
                         },
                         inProgress: { _ in
                            placeholder
                         },
                         failure: { error, retry in
                            placeholder
                         },
                         content: { image in
                            image
                         }
                )
                .foregroundColor(.white)
                .grayscale(0.3)
                .frame(width: 150, height: 150)
                .clipped()
    
            }
            Button(action: {
                withAnimation{
                    url = url.absoluteString.contains("sunfish") ? ContentView.horseURL : ContentView.fishURL
                }
            }, label: {
                Text("Show \(url.absoluteString.contains("sunfish") ? "horse" : "fish")")
            })
    
            Text("When the placeholder is visible (important), if you tap 'Hide image' below, and then tap 'Show image', it will only then correctly show the horse and toggling between the two images will work as expected.")
                .padding()
    
            Button(action: {
                withAnimation{
                    self.show.toggle()
                }
            }, label: {
                Text(show == true ? "Hide image" : "Show image")
            })
        }
    }
    
    
    bug fixed 
    opened by montehurd 6
  • Accessibility Help

    Accessibility Help

    In utilizing URLImage I've noticed that the rendered images are not accessibility via the iOS Accessibility Inspector and Reader systems. Is there a method to achieve this that I'm ignorant of or can this be a feature added down the line for this project?

    enhancement 
    opened by RaymondG-kr 0
  • Remove in memory cached images and load new ones

    Remove in memory cached images and load new ones

    Hi all, I am currently evaluating this library. I have cached the images using URLImageOptions - InMemory store type in one of my SwiftUI View. I tried to delete cached images from in memory using removeallImages() method but it did not work for me.

    bug 
    opened by princesojitra 0
  • Is it possible to forget all downloaded content each 15 minutes?

    Is it possible to forget all downloaded content each 15 minutes?

    Hi all! I am currently evaluating this library. So far it works nice, but I try to find an option to forget all the downloaded images, delete them from the cache (memory and file) and reload the images already on screen with new ones. Is this easily possible? Thanks for any hint! Marc

    enhancement 
    opened by TheMMstick 0
  • URLImageFileStore.init(fileIndex:) now public

    URLImageFileStore.init(fileIndex:) now public

    This patch allows to customize path to file storage:

           ```
             let fileIndexConfiguration = FileIndex.Configuration(
                  name: "URLImage",
                  filesDirectoryName: "images",
                  directoryURL: /* OUR PATH */
            )
            let fileIndex = FileIndex( configuration: fileIndexConfiguration )
    
            let urlImageService = URLImageService(
                  fileStore: URLImageFileStore( fileIndex: fileIndex ), // <-- this now public, otherwise will not compile
                  inMemoryStore: URLImageInMemoryStore()
            )
    
    opened by sergey-ilyin 0
Releases(3.0.0)
  • 3.0.0(May 10, 2021)

    • Version 3 redefines how URLImage uses caching. The package uses protocol cache by default, and can use local store if needed.
    • Configuration options can now be set using environment values.
    • There's also some small tweaks and refinements to make the package simpler.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Oct 22, 2020)

    Welcome all new URLImage v2.0. Created using best parts of battle tested v0.9 and new structure, URLImage become simpler and more stable.

    Source code(tar.gz)
    Source code(zip)
  • 0.9.11(Mar 17, 2020)

Owner
Dmytro Anokhin
iOS developer. https://dmytro-anokhin.medium.com/
Dmytro Anokhin
Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier.

SBPAsyncImage Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier. AsyncImage is a view that asynchronously loads an

Yutaro Muta 48 Dec 16, 2022
AsyncImageExample An example project for AsyncImage. Loading images in SwiftUI article.

AsyncImageExample An example project for AsyncImage. Loading images in SwiftUI article. Note: The project works in Xcode 13.0 beta (13A5154h).

Artem Novichkov 4 Dec 31, 2021
SwiftUI view that download and display image from URL and displaying Activity Indicator while loading .

ViewWithActivityIndicator ViewWithActivityIndicator is a SwiftUI view that download and display image from URL and displaying Activity Indicator while

Ali Adam 28 Feb 3, 2022
An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and  Watch.

KFSwiftImageLoader KFSwiftImageLoader is an extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memor

Kiavash Faisali 343 Oct 29, 2022
A lightweight generic cache for iOS written in Swift with extra love for images.

Haneke is a lightweight generic cache for iOS and tvOS written in Swift 4. It's designed to be super-simple to use. Here's how you would initalize a J

Haneke 5.2k Dec 11, 2022
🚀SwiftUI Image downloader with performant LRU mem/disk cache.

Progressive concurrent image downloader for SwiftUI, with neat API and performant LRU mem/disk cache.

Cheng Zhang 42 Sep 24, 2022
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Nes 534 Jan 3, 2023
Asynchronous image downloader with cache support as a UIImageView category

This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like UIImageView, UIButton, M

null 24.4k Jan 5, 2023
DGImageView - Asynchronous image downloader with cache. Supports gif too

DGImageView Installation Usage DGImageView Asynchronous image downloader with cache. Supports gif, memory cache, disk cache features. Installation Xco

donggyu 1 Jan 1, 2022
This simple cordova plugin will download picture from an URL and save to IOS Photo Gallery.

Photo Viewer This plugin is intended to download a picture from an URL into IOS Photo library.. How to Install Cordova: cordova plugin add https://git

Alwin jose 1 Oct 23, 2021
URLImage is a package that holds an easy way of showing images from an URL.

URLImage Overview URLImage is a package that holds an easy way of showing images from an URL. Usually this processes should take the following process

Ramón Dias 1 Nov 1, 2021
A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.

Longinus Longinus is a pure-Swift high-performance asynchronous web image loading,caching,editing framework. It was learned from Objective-C web image

Qitao Yang 290 Dec 17, 2022
Lightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!

Asyncrounously download and display images in Swift UI. Supports progress indicators, placeholders and image transitions. RemoteImageView Asyncrounous

Callum Trounce 192 Dec 7, 2022
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

Evgenii Neumerzhitckii 330 Sep 9, 2022
A Swift/SwiftUI utility for caching and displaying images in SwiftUI Views

A Swift/SwiftUI utility for caching and displaying images asynchronously. Built with Swift 5.5 and works with async/await.

王雪铮 Xuezheng Wang 1 May 5, 2022
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

Adnan Yousaf 11 Jan 10, 2022
CTPanoramaView is a library that displays spherical or cylindrical panoramas with touch or motion based controls.

CTPanoramaView is a high-performance library that uses SceneKit to display complete spherical or cylindrical panoramas with touch or motion based controls.

Salih Cihan Tek 1k Jan 2, 2023
App that Displays the NASA Photo of Day

SpacePod We'll progressively build a small SwiftUI app that displays the NASA ph

Kern Jackson 6 Nov 6, 2022
NASAPictureOfTheDay - An app that displays pictures from the NASA APOD API

NASA Picture of the day This is an app that displays pictures from the NASA APOD

Dhaval Rajani 0 Jan 29, 2022