Skip to content

Commit 4c4aa3d

Browse files
committed
add fetch helper method
1 parent b1d36d6 commit 4c4aa3d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/lib/cloudinary.cfc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,5 +434,26 @@
434434

435435
<cfreturn stResult>
436436
</cffunction>
437-
437+
438+
<cffunction name="fetch" output="false" returntype="string" hint="Return cloudinary url of cropped image.">
439+
<cfargument name="sourceURL" required="true" type="string">
440+
<cfargument name="cropParams" required="true" type="struct" hint="width,height,crop,format">
441+
442+
<cfset var stResult = structNew() />
443+
<cfset var endpoint = getAPIEndpoint()>
444+
<cfset var method = "image/fetch">
445+
<cfset var transform = getTransform(argumentCollection=arguments.cropParams)>
446+
447+
<cfset var fetchURL = "#endpoint#/#method#/#transform#/">
448+
<cfset var fileURL =arguments.sourceURL>
449+
450+
<cfif (len(fileURL) gt 2 && left(fileURL, 2) == "//")>
451+
<cfset fileURL = "http:" & fileURL>
452+
</cfif>
453+
454+
<cfset fileURL = fetchURL & urlEncode(fileURL)>
455+
456+
<cfreturn fileURL />
457+
</cffunction>
458+
438459
</cfcomponent>

0 commit comments

Comments
 (0)