I created an image upload for some projects. Having dealt with image uploads in the past I decided that I would just do some after hours work in order build one that I could give to the designers and let them go to town with it without hopefully needing my help. I did this like many plugins with some settings. So for each upload the designer has a list of settings where they can specify MIME types, destinations, sources, names, database table names, and so forth. One setting that is available is the ability to specify a set of sizes to resize the original image to.
While I naturally wanted to pass these values in as an array of values that my method could use to do the actual resizing I knew that each time the upload was implemented I would have to stop what I was doing to create the array of images and their resizing data. Not interested.
My solution was what I’m calling here a complex list. By complex I simply mean that it has two sets of delimiters in it. In my case commas and semi-colons. I chose this route over the array because it’s something more along the designers line of work. No fancy methods and square brackets. Just some good ole’ quotes, commas, and semi-colons. So let’s look at an example of a complex list, and then we’ll take a look at a method that will convert that list into a struct that the image upload method can work with.
The Calling Page
<!--- SET A STRING THAT CONTAINS IMAGE DATA IN THE FORM OF WIDTH, HEIGHT, TYPE; WIDTH, HEIGHT, TYPE; AND SO ON. SEMI-COLONS SEPARATE IMAGES AND COMMAS SEPARATE IMAGE SPECIFIC DATA. ---> <cfset VARIABLES.images = "200,200,large;150,150,medium;100,100,small"> <!--- RUN METHOD TO CONVERT DATA LIST TO STRUCT ---> <cfinvoke component="path.to.cfc.complex_lists" method="convertComplexList" returnVariable="complex_lists" > <!--- PASS IN LIST ABOVE ---> <cfinvokeargument name="imagesizes" value="#VARIABLES.images#" /> </cfinvoke> <!--- DUMP THE STRUCT ---> <cfdump var="#complex_lists#">



At Monserrate Monastery in Bogotá, Colombia.