-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #11 linkTo(attachment=x, attachmentStyle='small'). Changes ima…
…geTag() to attachmentImageTag() to avoid name clashes with other plugins like ColdRoute.
- Loading branch information
Chris Peters
committed
Mar 16, 2012
1 parent
cc45d74
commit 740e3e8
Showing
5 changed files
with
170 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
= CFWheels Attachments Plugin | ||
|
||
Add support for file uploads to your [CFWheels][1] model with the `hasAttachment()` function. Also provides `attachmentImageTag()` and `attachmentLinkTo()` view helpers. | ||
|
||
Automatically resize uploaded images to a set of "styles" that you define. (For example, you could automatically resize for `thumbnail`, `small`, `medium`, `large`, etc.) | ||
|
||
Overrides `fileField()` to work better with `<cffile>` and [nested properties][2]. | ||
|
||
== Dependencies | ||
|
||
You must also install the [JSON Properties plugin][3] for the Attachments plugin to work. | ||
|
||
== Documentation | ||
|
||
For more documentation, install the Attachments plugin and click the _Attachments_ link in the _Plugins_ section of the debugging section of your CFWheels application's footer. | ||
|
||
== Credits | ||
|
||
This plugin was created by [James Gibson][4] and [Chris Peters][5] with support from [Liquifusion Studios][6]. | ||
|
||
[1]: http://cfwheels.org/ | ||
[2]: http://cfwheels.org/docs/chapter/nested-properties | ||
[3]: https://github.com/liferealized/cfwheels-json-properties | ||
[4]: http://iamjamesgibson.com/ | ||
[5]: http://www.clearcrystalmedia.com/ | ||
[6]: http://liquifusion.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<cffunction name="attachmentLinkTo" returntype="string" access="public" output="false" hint="Creates a link to an attachment uploaded via the Attachments plugin. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."> | ||
<cfargument name="text" type="string" required="false" default="" hint="The text content of the link."> | ||
<cfargument name="attachment" required="false" default="" hint="Pass an attachment property struct here to use an attachment. Can be a struct or JSON-formatted."> | ||
<cfargument name="attachmentStyle" required="false" default="" hint="Pass an attachment style name here to use a particular attachment's style."> | ||
<cfscript> | ||
var loc = { | ||
linkToArgs=Duplicate(arguments), | ||
skip="text,confirm,route,controller,action,key,params,anchor,onlyPath,host,protocol,port" | ||
}; | ||
// Remove non-string values | ||
StructDelete(loc.linkToArgs, "attachment"); | ||
StructDelete(loc.linkToArgs, "attachmentStyle"); | ||
if (IsJson(arguments.attachment)) | ||
arguments.attachment = DeserializeJson(arguments.attachment); | ||
if (Len(arguments.attachmentStyle)) | ||
loc.linkToArgs.href = arguments.attachment.styles[arguments.style].url; | ||
else | ||
loc.linkToArgs.href = arguments.attachment.url; | ||
if (!Len(loc.linkToArgs.text)) | ||
loc.linkToArgs.text = loc.linkToArgs.href; | ||
loc.returnValue = $element(name="a", skip=loc.skip, content=loc.linkToArgs.text, attributes=loc.linkToArgs); | ||
</cfscript> | ||
<cfreturn loc.returnValue> | ||
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters