Placeholder Images for every case. Webdesign or Print. It’s simple and absolutely free! Just put the custom url in your code like this:to get your FPO / dummy image.
-
-
- http://lorempixel.com/400/200 to get a random picture of 400 x 200 pixels
- <http://lorempixel.com/g/400/200 to get a random gray picture of 400 x 200 pixels
- <http://lorempixel.com/400/200/sports to get a random picture of the sports category
- <http://lorempixel.com/400/200/sports/1 to get picture no. 1/10 from the sports category
- <http://lorempixel.com/400/200/sports/Dummy-Text …with a custom text on the random Picture
- http://lorempixel.com/400/200/sports/1/Dummy-Text …with a custom text on the selected Picture
self.profileImageView.setRandomDownloadImage(80, height: 80)
func setRandomDownloadImage(_ width: Int, height: Int) {
if self.image != nil {
self.alpha = 1
return
}
self.alpha = 0
let url = URL(string: “http://lorempixel.com/\(width)/\(height)/")!
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 15
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
let session = URLSession(configuration: configuration)
let task = session.dataTask(with: url) { (data, response, error) in
if error != nil {
return
}
if let response = response as? HTTPURLResponse {
if response.statusCode / 100 != 2 {
return
}
if let data = data, let image = UIImage(data: data) {
DispatchQueue.main.async(execute: { () -> Void in
self.image = image
UIView.animate(withDuration: 0.3, animations: { () -> Void in
self.alpha = 1
}, completion: { (finished: Bool) -> Void in
})
})
}
}
}
task.resume()
}