If you're using a WYSIWYG control for formatting the blog posts, there's probably hooks you can use to do this sort of thing. I created a fairly rudimentary plugin once for WymEditor that did this. The existing "upload" button simply prompted for an img path, so the image obviously already had to be on the server and the client needed to know exactly where it was. Some people have created image browser plugins that make this simpler but they don't do uploads. Mine prompted the user to upload a file and also allowed for choosing id, class, and styles.
So, upload the image from within an iframe (because an AJAX request can't upload) and have your script re-size (to some maximum dimensions) and save the file within the files dir. I would create a subdir with that day's date (if it doesn't exist) and save it there. Then send back a JSON object with the full path from DOCUMENT_ROOT as well as the final width & height, and maybe other attributes (eg. style). Then add an img tag inline within the content. Jquery makes this pretty painless. The really great thing about doing it this way is that the img can be anywhere within the content and it shows up in your preview immediately. The downside is that the img is not recorded in the DB. That is, it *could be* but, since the img tag markup is embedded within the blog content, your Cake app has nothing to do with displaying it. So, recording it in the DB has few benefits. On Fri, Sep 11, 2009 at 11:41 AM, Theo McCaie <[email protected]> wrote: > I'm looking to serve up pictures with a blog post and hoping for > architectural advice. There can be any number of pictures any where in the > article. > > To create a post there is a form with a text area (for the blog) and a > picture upload field (and fields with info about the picture eg align right, > descripton etc). > Finally a small bit of java which replicates the inputs again so you can add > more blog or pictures, rinse and repeat. > > What is the best way do you guys think to implement this. Currently the file > is uploaded and a <img> tag is appended to the blog post and saved in the > data base. This isn't a great solution. > > I'd love to heat some ideas for a flexible way of storing, and editing this > data. > > Thanks > > Theo. > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
