image.cfc and custom fields (6.2)

瀏覽次數:13 次
跳到第一則未讀訊息

Phillip Rasmussen

未讀,
2013年9月20日 凌晨12:55:492013/9/20
收件者:farcr...@googlegroups.com
Hi,
I'm wondering if someone could point me the right direction.
This is what I'm trying to achieve:
When the source image is uploaded I want the ajax call to return some information in json. Specifically in this case the IPTC data form the uploaded image. ie use ImageGetEXIFMetadata and ImageGetIPTCMetadata
Then I can use jquery to populate the Title field among some custom ones.

For the life of me I can't find where the source image is doing the cfreturn. I can see that the ajax call is returning [] but I can't find where to intercept it and send back some more useful information.

<cfset stFile = getFileInfo(application.path.imageroot & stResult.value) />
<cfimage action="info" source="#application.path.imageroot##stResult.value#" structName="stImage" />
<cfset stJSON["value"] = stResult.value />
<cfset stJSON["filename"] = listlast(stResult.value,'/') />
<cfset stJSON["fullpath"] = application.url.imageroot & getDirectoryFromPath(stResult.value) & urlencodedformat(getFileFromPath(stResult.value)) />
<cfset stJSON["size"] = round(stFile.size/1024) />
<cfset stJSON["width"] = stImage.width />
<cfset stJSON["height"] = stImage.height />

It seems that the above code in image.cfc should be used but doesn't seem to be. Is it fallback stuff? Should I be looking at the ajax function in image.cfc?

My initial though was to do this with a beforeSave but the client really want to upload an image and edit the content inline rather than have to save it and then go back into it.

Any suggestions would be appreciated.

Regards
Phil

Blair McKenzie

未讀,
2013年9月20日 凌晨1:14:032013/9/20
收件者:Unname
The image formtool uses the Uploadify plugin. It makes one request with XHR to see if the file already exists (FarCry always returns no, or []), then a second request through Flash to upload the image. To hook into the response is a bit tricky, but something like this should do the job:

$j($fc.imageformtool(formprefix,propertyname)).bind("filechange",function(event,results){
    // your code here
});

To get the prefix you can either:

Hook into ft:object r_stPrefix="somevariable" (hint: not actually a struct)

OR

Override the image formtool edit function. Call super to get the default edit HTML, then tack your custom JS onto the end. To get the prefix:
<cfset var prefix = left(arguments.fieldname,len(arguments.fieldname)-len(arguments.stMetadata.name)) />

Blair


--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
---
You received this message because you are subscribed to the Google Groups "farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to farcry-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Phillip Rasmussen

未讀,
2013年9月20日 晚上8:29:232013/9/20
收件者:farcr...@googlegroups.com
Hi Blair,
Cheers for that.
So I guess I should make an ajaxSomething function in image.cfc to return the required data then.
I'll have a go on Monday.
Regards
Phil
回覆所有人
回覆作者
轉寄
0 則新訊息