Skip to content

Commit

Permalink
AlamofireImageKit Version - 1.0.1.01
Browse files Browse the repository at this point in the history
AlamofireImageKit Version - 1.0.1.01
  • Loading branch information
arzrasel committed Mar 8, 2021
1 parent 4205ae0 commit 1398d05
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Source/AlamofireImageKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension UIImageView {
public func onLoadAlamofireImage(from urlLocation: String) {
onLoadImage(from: urlLocation)
}
public func onLoadImage(from urlLocation: String) {
public func onLoadImage(from urlLocation: String, isCheckImage: Bool = false) {
if urlLocation.isEmpty == true {
return
}
Expand All @@ -31,8 +31,21 @@ extension UIImageView {
if imgFromCache != nil{
self.image = imgFromCache
} else {
do {
_ = try NSData(contentsOf: url, options: NSData.ReadingOptions())
if isCheckImage {
do {
_ = try NSData(contentsOf: url, options: NSData.ReadingOptions())
self.af_setImage(
withURL: url,
placeholderImage: nil,
filter: AspectRatioScaledToWidthFilter(width: self.frame.size.width),
completion: { (rs) in
imageCache.add(self.image!, for: urlRequest, withIdentifier: name)
}
)
} catch {
print("ERROR: \(error)")
}
} else {
self.af_setImage(
withURL: url,
placeholderImage: nil,
Expand All @@ -41,8 +54,6 @@ extension UIImageView {
imageCache.add(self.image!, for: urlRequest, withIdentifier: name)
}
)
} catch {
print("ERROR: \(error)")
}
}
}
Expand All @@ -57,7 +68,7 @@ extension UIImageView {
public init(width: CGFloat) {
self.width = width
}

/// The filter closure used to create the modified representation of the given image.
public var filter: (Image) -> Image {
return { image in
Expand Down

0 comments on commit 1398d05

Please sign in to comment.