ImageLoading
ImageLoading is providing set of functions for downloading of images from URLs.
public protocol ImageLoading: AnyObject
Inheritance
AnyObject
Default Implementations
loadImage(into:url:imageCDN:placeholder:resize:preferredSize:completion:)
@discardableResult
func loadImage(
into imageView: UIImageView,
url: URL?,
imageCDN: ImageCDN,
placeholder: UIImage? = nil,
resize: Bool = true,
preferredSize: CGSize? = nil,
completion: ((_ result: Result<UIImage, Error>) -> Void)? = nil
) -> Cancellable?
loadImages(from:placeholders:loadThumbnails:thumbnailSize:imageCDN:completion:)
func loadImages(
from urls: [URL],
placeholders: [UIImage],
loadThumbnails: Bool = true,
thumbnailSize: CGSize = .avatarThumbnailSize,
imageCDN: ImageCDN,
completion: @escaping (([UIImage]) -> Void)
)
Requirements
loadImage(using:cachingKey:completion:)
Load an image from using the given URL request
@discardableResult
func loadImage(
using urlRequest: URLRequest,
cachingKey: String?,
completion: @escaping ((_ result: Result<UIImage, Error>) -> Void)
) -> Cancellable?
Parameters
urlRequest
: TheURLRequest
object used to fetch the imagecachingKey
: The key to be used for caching this imagecompletion
: Completion that gets called when the download is finished
loadImage(into:url:imageCDN:placeholder:resize:preferredSize:completion:)
Load an image into an imageView
from the given URL
@discardableResult
func loadImage(
into imageView: UIImageView,
url: URL?,
imageCDN: ImageCDN,
placeholder: UIImage?,
resize: Bool,
preferredSize: CGSize?,
completion: ((_ result: Result<UIImage, Error>) -> Void)?
) -> Cancellable?
Parameters
imageView
: TheUIImageView
object in which the image should be loadedurl
: TheURL
from which the image is to be loadedimageCDN
: TheImageCDN
object which is to be usedplaceholder
: The placeholderUIImage
to be usedresize
: Whether to resize the image or notpreferredSize
: The preferred size of the image to be loadedcompletion
: Completion that gets called when the download is finished
loadImages(from:placeholders:loadThumbnails:thumbnailSize:imageCDN:completion:)
Load images from a given URLs
func loadImages(
from urls: [URL],
placeholders: [UIImage],
loadThumbnails: Bool,
thumbnailSize: CGSize,
imageCDN: ImageCDN,
completion: @escaping (([UIImage]) -> Void)
)
Parameters
urls
: The URLs to load the images fromplaceholders
: The placeholder images. Placeholders are used when an image fails to load from a URL. The placeholders are usedrotationally
loadThumbnails
: Should load the images as thumbnails. If this is set totrue
, the thumbnail URL is derived from theimageCDN
objectthumbnailSize
: The size of the thumbnail. This parameter is used only if theloadThumbnails
parameter is trueimageCDN
: The imageCDN to be usedcompletion
: Completion that gets called when all the images finish downloading