Skip to content

Instantly share code, notes, and snippets.

@venkatchm
Last active January 31, 2017 06:45

Revisions

  1. venkatchm renamed this gist Jan 31, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.txt → cloudinaryfetchauthenticatedimages.txt
    Original file line number Diff line number Diff line change
    @@ -11,10 +11,10 @@
    guard let _transformation = transformation else {
    return nil
    }
    let options = [CloudinaryConstants.accessType: CloudinaryConstants.fetch,
    CloudinaryConstants.transformation: _transformation,
    CloudinaryConstants.signURL: CloudinaryConstants.isSignURL,
    CloudinaryConstants.secure: true] as [String : Any]
    let options = ["type": "fetch",
    "transformation": _transformation,
    "sign_url": "YES",
    "secure": true] as [String : Any]
    let convertedURL = cloudinary?.url(_imageUrl, options: options)

    return URL(string: convertedURL!)
  2. venkatchm created this gist Jan 31, 2017.
    25 changes: 25 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    static func getCroppedImageUrl(imageUrl: String?, width: CGFloat, height: CGFloat) -> URL? {
    guard let _imageUrl = imageUrl else {
    return nil
    }

    do {
    let cloudinary = try CLCloudinary(url: Configuration.cloudinaryURL())
    let transformation = CLTransformation()
    transformation?.width = width
    transformation?.height = height
    guard let _transformation = transformation else {
    return nil
    }
    let options = [CloudinaryConstants.accessType: CloudinaryConstants.fetch,
    CloudinaryConstants.transformation: _transformation,
    CloudinaryConstants.signURL: CloudinaryConstants.isSignURL,
    CloudinaryConstants.secure: true] as [String : Any]
    let convertedURL = cloudinary?.url(_imageUrl, options: options)

    return URL(string: convertedURL!)
    }
    catch {
    return nil
    }
    }