> I certainly don't think this should be in the model though (or even a > behavior). Maybe a helper would make sense if you were serving up > different sizes based on the user's request.
Why? If he is modeling the Image, maybe is because it's a important concept for his application and must be considered data int that context, thus having data manipulation code in the model is the right approach. If you are in the need for having various sizes, depending on the view then consider this: * An Image model having the true resizing logic. * An Images controller with it's custom routes so having i.e. /img/user/5/50x30/avatar.jpg dispatching to a resize method in your images controller that parses the URL, finds and resizes the image and then stores it under the requested path so, next time it's fetched from webroot. * An Image helper encapsulating the resizing logic so you can do in views: echo $image->resize($user['image'], array( 'size' => '50x30')); Regards, - Dardo Sordi. > On Thu, May 29, 2008 at 5:51 PM, aranworld <[EMAIL PROTECTED]> wrote: >> >> Time for a semantic question. >> >> I have a controller for images, which handles the process of uploading >> an image to my website. >> >> Information about the image -- caption, filename, etc. -- is stored in >> the database with a model named Image. >> >> I have some functions which generate various sized versions of the >> uploaded image. One creates a square thumbnail version, another >> created a user specified sized version. >> >> Right now those imagesizing functions are in the ImagesController ... >> but I'm wondering if this is the best location for them. >> >> Should these functions be in an component, instead? Or should they be >> in the Image model? It seems strange to put them in the model, since >> they don't directly have anything to do with the image data, but maybe >> they actually belong there? >> >> >> > >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
