Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Form tools provide a variety of powerful image manipulation options.

Image field types need to be used in conjunction with a string data type. Formtools expects to store the path to the media asset in the database field.

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

ftCreateFromSourceOptionftCreateFromSourceDefault

Generate image from source image. Requires a populated property called "SourceImage"ftSourceField to be specified.

false

 

 

 

 

 

 

...

ftSourceField

Image property from which an autogenerated image should be derived.

A nominated content type property.

ftAllowUpload

Boolean to allow an image to be uploaded for this image. Only relevant if the image can be autogenerated.

Default; true.

Combining Image Properties

You can tie image properties together for generating images of specific dimensions from a source image. A typical example is providing a thumbnail image.

<!------------------------------------------------------------------------ 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>
Code Block
titlebeforeSave() method required
Creating a Thumbnnail from a Source Image

<cfproperty name="imgMugshot" type="string" hint="Mugshot." required="false" default="" 
    ftlabel="Mugshot" fttype="image" ftimagewidth="200" ftdestination="/images/myprofile/imgmugshot" />
<cfproperty name="imgMugshotThumb" type="string" hint="Mugshot thumbnail." required="false" default="" 
    ftlabel="Mugshot Thumb" fttype="image" ftimagewidth="80" ftimageheight="80" ftthumbnail="true" 
    ftCreateFromSourceDefault="true" ftSourceField="imgMugshot" ftdestination="/images/myprofile/imgmugshotthumb" />

Setting Default Date Values

Often you want to designate a default date value that is dynamic and based on the current date or some other environment variable. The simplest approach is to set an ftDefault variable and ftdefaulttype set to evaluate.

Code Block
titleDynamically Setting a Default Date Value

<cfproperty 
  ftseq="12" ftfieldset="Publishing Details" ftwizardStep="General Details" 
  name="expiryDate" type="date" hint="The date that a news object is removed from the web site" required="no" default="" 
  ftDefaultType="Evaluate" ftDefault="DateAdd('d', 5, now())" ftType="datetime" 
  ftDateFormatMask="dd mmm yyyy" ftTimeFormatMask="hh:mm tt" ftToggleOffDateTime="true" ftlabel="Expiry Date" />
Info

default corresponds to the default set in the database. Its a data type default.
ftdefault on the other hand is a formtool default. That is, it relates to the UI control.