image.cfc - workaround for a missing 'mode' attribute in the <cfimage> tag

Description

There can be problems with deleting files ("standard" and "thumbnail" images) from the image library under a Linux/Unix enviroment. These problems are caused by the Unix file rights, which are created by the <cfimage> tag in the 'image.cfc' (normally "644"). Essentially this is caused by a missing 'mode' attribute in the <cfimage> tag.

This small workaround in the 'image.cfc' works for me. I only placed the following code after each <cfimage> tag:

<!--- Workaround for missing 'mode' attribute in the <cfimage> tag :: Set UNIX file rights to 'user:group' --->
<cffile action="rename" source="#imageDestination#" destination="#imageDestination#" mode="664" />

Code-Example from line 1512 on (image.cfc / SVN-Revision 11448):
---------------------------------------------------------------
<cfif arguments.ResizeMethod eq "none">
<cfif bModified>
<cfimage action="write" source="#newImage#" destination="#imageDestination#" overwrite="true" />
<!--- Workaround for missing 'mode' attribute in the <cfimage> tag :: Set UNIX file rights to 'user:group' --->
<cffile action="rename" source="#imageDestination#" destination="#imageDestination#" mode="664" />
<cfelse>
<!--- No changes, the file is already in place ... we're done --->
</cfif>
<cfelse>
<cfscript>
stImageAttributeCollection.action = "write";
stImageAttributeCollection.source = newImage;
stImageAttributeCollection.destination = imageDestination;
stImageAttributeCollection.overwrite = "true";
if(right(imageDestination, 4) eq ".jpg" or right(imageDestination, 5) eq ".jpeg"){
stImageAttributeCollection.quality = arguments.quality; // This setting (from Adobe) is for jpg images only and would cause errors if used on other image types
}
</cfscript>

<cfimage attributeCollection="#stImageAttributeCollection#" />
<!--- Workaround for missing 'mode' attribute in the <cfimage> tag :: Set UNIX file rights to 'user:group' --->
<cffile action="rename" source="#imageDestination#" destination="#imageDestination#" mode="664" />

<cfset stResult.filename = listlast(stImageAttributeCollection.destination,"/\") />
</cfif>
---------------------------------------------------------------

Environment

FarCry 6.0.8 - Debian-Linux LENNY 5.0 - MySQL 5.0.51a-24 - ColdFusion 8 (Multiserver Install)

Activity

Show:
Blair McKenzie
December 22, 2010 at 12:38 AM

This patch has been applied.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created December 18, 2010 at 7:26 AM
Updated December 22, 2010 at 12:38 AM
Resolved December 22, 2010 at 12:38 AM