ok, i have made an attempt at converting a php function. unfortunately it does 
not quite work. i think i am close ??

<cffunction name="resize_markup" access="public" returntype="string" 
output="false">
                <cfargument name="markup" type="string" required="yes">
                <cfargument name="width" type="numeric" required="false">
                <cfargument name="height" type="numeric" required="false">
                
                <cfset var patterns = arrayNew(1)>
                <cfset var replacements = arrayNew(1)>
                
                <cfif isDefined("arguments.width")>
                
                        <cfscript>
                                pattern = 'width="([0-9]+)"';
                                arrayAppend(patterns, pattern);
                                
                                pattern = 'width:([0-9]+)';
                                arrayAppend(patterns, pattern);
                                
                                replacement = 'width="' & arguments.width & '"';
                                arrayAppend(replacements, replacement);
                                
                                replacement = 'width:' & arguments.width;
                                arrayAppend(replacements, replacement);
                        </cfscript>     
                
                </cfif>
                
                <cfif isDefined("arguments.height")>
                
                        <cfscript>
                                pattern = 'height="([0-9]+)"';
                                arrayAppend(patterns, pattern);
                                
                                pattern = 'height:([0-9]+)';
                                arrayAppend(patterns, pattern);
                                
                                replacement = 'height="' & arguments.height & 
'"';
                                arrayAppend(replacements, replacement);
                                
                                replacement = 'height:' & arguments.height;
                                arrayAppend(replacements, replacement);
                        </cfscript>     
                
                </cfif>
                
                <cfloop from="1" to="#arrayLen(patterns)#" index="idx">
                        
                        <cfset new_string = REReplaceNoCase(arguments.markup, 
patterns[idx], replacements[idx], "All")>
                        
                </cfloop>
                
                <cfreturn new_string />
                
        </cffunction> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323102
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to