I'm attempting to upload an image file into an Image asset (the latter I've created via the JS API). I'm mimicking the EES way of submitting a form to an iframe.
My solution works inconsistently and I wondered whether anyone on here could help me understand why it only works about half the time.
So you are trying to replace an image for an already created Image File Asset?
Yes indeed; the Image File asset may be empty (after it's first created via the JS API createAsset() function), or have an image already in it. In the latter case I'm attempting to replace it.
Yes indeed; the Image File asset may be empty (after it's first created via the JS API createAsset() function), or have an image already in it. In the latter case I'm attempting to replace it.
And you are not wanting to use the EES or Simple Edit?
And you are not wanting to use the EES or Simple Edit?
We'll still be making the EES available for more experienced web content editors. But we've found that, for the average user, having to first upload an image and then, separately, embed it within the page (coupled with the Java Asset Map UI) is not really intuitive. I realise there's a way to upload and embed within the Add Picture popup, but that is equally confusing to users - we don't want them having to do the 'Use Me' thing.
Hence I'm developing a UI which will allow users to upload and embed an image into a page in a single step. Trying to mimic the EES code which uploads into an empty asset type seemed like a sensible way to overcome the upload issue.
I've also got users who couldnt cope with anything too complicated, and built our own very very simple editing feature using the JS api. Rather than creating the image asset and then figuring out how to post an actual image into it, I decided to use an assetbuilder asset, so the create and post of the image all happen in one step. Using Firebug and/or Fiddler it was pretty easy to see the various POST parameters etc that were needed... and it looked a bit easier than what you are trying to mimic from EES. I did consider doing the create and upload separately like you are, and it was a while ago so I dont remember exactly why I abandoned that approach but I must have hit some kind of snag.
To make life really easy for my users I took the Adobe Flash SWFUpload gizmo and mashed that together with a little UI that lets them load a JPG from local disk, draw a crop rectangle on it and then upload it (which resizes the image to a sensible size and does the POST to the asset builder). But thats a whole different story...!
We'll still be making the EES available for more experienced web content editors. But we've found that, for the average user, having to first upload an image and then, separately, embed it within the page (coupled with the Java Asset Map UI) is not really intuitive. I realise there's a way to upload and embed within the Add Picture popup, but that is equally confusing to users - we don't want them having to do the 'Use Me' thing.
Hence I'm developing a UI which will allow users to upload and embed an image into a page in a single step. Trying to mimic the EES code which uploads into an empty asset type seemed like a sensible way to overcome the upload issue.
Thanks for the info, guys. I may just employ an Asset Builder (and iframe) if my impasse proves to be insurmountable :)
Cheers.
I think the one gotcha with trying to replicate what the EES is doing, is that if you upgrade, it might break. I would stick with the asset builder in an iFrame.