Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Image

Form tools provide a variety of powerful image manipulation options.

Attribute

Description

Default Value

ftStyle

Inline style attributes.

(blank)

ftDestination

Location of image; relative to the web root.

/images

ftImageWidth

Width to resize image to.

(blank)

ftImageHeight

Height to resize image to.

(blank)

ftThumbnail

Boolean toggle to pad out the image to the required width/height.

false

ftThumbnailBGColor

Is this replaced by ftPadColor?? Background colour for thumbnail padding. Colour name or web hexadecimal colour code.

white

ftPadColor

Background colour for thumbnail padding. Colour name or web hexadecimal colour code with double ## prefix.

white

ftThumbnailBevel

Apply bevel edge to the thumbnail.

false

ftAutoGenerateType

Options for autogenerating the image.

FitInside or Pad

ftCreateFromSourceOption

Generate image from source image. Requires a populated property called "SourceImage".

false

 

 

 

 

 

 

Not sure how the source image is determined. I think it's got to be a property called "sourceimage".

beforeSave() method required
<!------------------------------------------------------------------------
object methods 
------------------------------------------------------------------------->	
<cffunction name="BeforeSave" access="public" output="true" returntype="struct">
	<cfargument name="stProperties" required="yes" type="struct">
	<cfargument name="stFields" required="yes" type="struct">
		
	<!--- IS THERE A SOURCE IMAGE PROVIDED? --->
	<cfif structKeyExists(arguments.stProperties, "SourceImage") AND len(arguments.stProperties.SourceImage)>
		
		<cfset stObject = getData(objectid=stproperties.objectid) />
		<cfset oImage = createobject("component", "farcry.farcry_core.packages.formtools.image") />
		
		<cfset lImageFields = "" />
		<cfloop list="#StructKeyList(arguments.stFields)#" index="i">

			<cfif structKeyExists(arguments.stFields[i].metadata, "ftType") AND arguments.stFields[i].metadata.ftType EQ "Image" AND i NEQ "SourceImage" >
				<cfif structKeyExists(arguments.stFormPost, i) AND structKeyExists(arguments.stFormPost[i].stSupporting, "CreateFromSource") AND ListFirst(arguments.stFormPost[i].stSupporting.CreateFromSource)>
					<cfset lImageFields = ListAppend(lImageFields, i) />
				</cfif>
			</cfif>

		</cfloop>

		<cfloop list="#lImageFields#" index="i">
			<cfparam name="arguments.stFields['#i#'].metadata.ftDestination" default="#application.config.image.StandardImageURL#">		
			<cfparam name="arguments.stFields['#i#'].metadata.ftImageWidth" default="#application.config.image.ThumbnailImageWidth#">
			<cfparam name="arguments.stFields['#i#'].metadata.ftImageHeight" default="#application.config.image.ThumbnailImageHeight#">
			<cfparam name="arguments.stFields['#i#'].metadata.ftAutoGenerateType" default="FitInside">
			<cfparam name="arguments.stFields['#i#'].metadata.ftPadColor" default="##ffffff">
				
			<cfset stArgs = StructNew() />
			<cfset stArgs.Source = "#application.path.project#/www#arguments.stProperties.SourceImage#" />
			<cfset stArgs.Destination = "#application.path.project#/www#arguments.stFields['#i#'].metadata.ftDestination#" />
			<cfset stArgs.Width = "#arguments.stFields['#i#'].metadata.ftImageWidth#" />
			<cfset stArgs.Height = "#arguments.stFields['#i#'].metadata.ftImageHeight#" />
			<cfset stArgs.AutoGenerateType = "#arguments.stFields['#i#'].metadata.ftAutoGenerateType#" />
			<cfset stArgs.padColor = "#arguments.stFields['#i#'].metadata.ftpadColor#" />
				
			<cfset stGenerateImageResult = oImage.GenerateImage(Source="#stArgs.Source#", Destination="#stArgs.Destination#", Width="#stArgs.Width#", Height="#stArgs.Height#", AutoGenerateType="#stArgs.AutoGenerateType#", padColor="#stArgs.padColor#") />
				
			<cfif stGenerateImageResult.bSuccess>
				<cfset stProperties['#i#'] = "#arguments.stFields['#i#'].metadata.ftDestination#/#stGenerateImageResult.filename#" />
			</cfif>
				
		</cfloop>
		
	</cfif>
	<cfset stProperties = super.BeforeSave(stProperties=stproperties, stFields=stFields) />
	
	<cfreturn stProperties />
		
</cffunction>
  • No labels