Media Plugin
I'm using David Persson's excellent Media plugin, and found an odd bug. I use it in a Gallery plugin, and when the gallery contains a lot of images (maybe 100? haven't been able to determine exactly), deletion doesn't work. I'll use the usual mechanism of deleting, and the image doesn't get deleted. In this case, that means checking a checkbox next to each attachment and clicking the Save and Continue button. Every checked image is supposed to be deleted. Works fine if there's only 10 or so images, but this one client has hundreds. There isn't much custom code in the Gallery plugin, and the Media plugin is pretty much stock. Any ideas? Need any more information? Thanks, Shannon -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
issues with media plugin generator behavior
Hey guys, I'm new to cakePHP and MVC as well so maybe I got some major design flaws in my attempt. Excuse my spelling as well since im not a native speaker. *What I'm trying to do:* I want to create a view where the user can re-crop uploaded images using the Jcrop Javascript lib http://deepliquid.com/content/Jcrop.html and the Media Plugin from David Persson https://github.com/bmcclure/CakePHP-Media-Plugin . *Setup:* All mediafiles are stored by the Attachment Model which is based of the one shipped with the Mediaplugin. Other Models can use the Attachment Model to store mediafiles. *My Attempt:* Step 1 (*View/Attachments/admin_edit.ctp*): Gather cropdata, data will injected to the form via javascript Step 2 (Controller/AttachmentsController.php) 2.1: Save attachment data 2.2: if attachment data was saved: process cropdata with use of *$this-Attachment-makeVersion($file, $instructions);* 2.3: redirect to attachments indexview using *$this-redirect(array($admin = true, 'controller' = 'attachments', 'action' = 'index'));* *Issue:* My general attempt is working, so all images get croped like i want them to but the following redirect isn't fired, instead a weird redirect to current action is executed somewhere. I narrowed it down to the *makeVersion() *method, when i comment that out, the attachment gets still saved and the redirect is working like it's supposed to. So it seems that *makeVersion() *has some weird sideeffect. Since i get redirected it is really hard to debug because i cannot inspect the request or check for errors. I tried with using debug();exit; to narrow it further down inside of the makeVersion() method but i really don't get this, theres no redirects called anywhere inside. *Code:* For anyone still reading and interested in helping me, check out the source here https://github.com/KingLoui/mediatest/blob/master/app/Controller/AttachmentsController.php . Thanks in advance for your effort! Cheers Mathias -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Media PLugin
of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others
Media Plugin Question - Move an existing record
I am using David Perssons media pluginhttps://github.com/davidpersson/mediain 1.3 environment and I have more of an advanced usage question. Basically, I have existing model records that rely on a model field (slug) as part of the path to the image. Since this is a join table, the user can change the association to another record, making the media path invalid. Basically I have videos that belong to a show, and the show slug is used as part of the path. When users change shows (if they accidentally place the video in the wrong show) the dirname path is now invalid and the file is in the wrong place. I am trying to figure out how/if I can use the media plugin to move the file from the original path, to a new path. I know how to do that using the beforeSave (detect change) and afterSave (move if needed) but I'd like to use the media plugin to make the move as it automatically handles filename changes (adding -2 if the file exists) and handles the paths for you. Any thoughts? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Deleting Media Plugin attachments
I'm using Media Plugin with 2.1 is the monolithic setup (i.e. using the Polymorphic behavior). For this I have a Project that hasMany Attachments. How do I delete an attachment without deleting the project? I get errors when I try to use $this-Project-Attachment-find(). -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
Just thought I'd post my slightly cleaner solution to this which makes use of a modified version of the attachments element in the media plugin. This allows you to use the attachment multiple times in a form for when you have different groups of attachments i.e. photos, files, videos etc. I'm no programmer, just a designer so there's probably a better way to do it but I don't know it :) To save me editing too much I'll just use my example of a ProjectProfile model: ProjectProfile.php ?php App::uses('AppModel', 'Model'); class ProjectProfile extends AppModel { var $name = 'ProjectProfile'; var $useDbConfig = 'default'; var $useTable = 'project_profiles'; var $actsAs = array('Media.Transfer', 'Media.Generator' ); public $belongsTo = array( 'Project' = array( 'className' = 'Project', 'foreignKey' = 'pjID' //'conditions' = '', //'fields' = '', //'order' = '' ) ); var $hasMany = array( 'Photo' = array( 'className' = 'Media.Attachment', 'order' = 'Photo.basename, Photo.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Photo.model' = 'ProjectProfile', 'Photo.group' = 'Photo'), 'dependent' = true), 'Attachment' = array( 'className' = 'Media.Attachment', 'order' = 'Attachment.basename, Attachment.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'ProjectProfile', 'Attachment.group' = 'Attachment'), 'dependent' = true) ); } ProjectProfilesControler.php ?php App::uses('AppController', 'Controller'); class ProjectProfilesController extends AppController { public function admin_edit($id = null) { $this-ProjectProfile-id = $id; if (!$this-ProjectProfile-exists()) { throw new NotFoundException(__('Invalid project profile')); } if ($this-request-is('post') || $this-request-is('put')) { //convert cakephp html5 file upload data array to media plugin required format $model = Inflector::classify($this-params['controller']); foreach ($this-request-data[$model]['assocAlias'] as $assocAlias) { $i = 0; foreach ($this-request-data[$model][$assocAlias.'files'] as $file) { $this-set($this-request-data[$assocAlias][$i]['model'] = $model); $this-set($this-request-data[$assocAlias][$i]['group'] = strtolower($assocAlias)); $this-set($this-request-data[$assocAlias][$i]['file'] = $this-request-data[$model][$assocAlias.'files'][$i]); $i++; } } if ($this-ProjectProfile-saveAll($this-request-data)) { $this-Session-setFlash(__('The project profile has been saved')); $this-redirect(array('action' = 'admin_edit', $id)); } else { $this-Session-setFlash(__('The project profile could not be saved. Please, try again.')); } } else { $this-request-data = $this-ProjectProfile-read(null, $id); } $projects = $this-ProjectProfile-Project-find('list', array('fields' = array('Project.pjID', 'Project.pntitle'))); $this-set(compact('projects')); } ? Then in the view/form: admin_edit.php div class=projectProfiles form ?php echo $this-Form-create('ProjectProfile', array('type'='file'));? fieldset legend?php echo __('Admin Edit Project Profile'); ?/legend ?php echo $this-Form-input('id'); echo $this-Form-input('pjID', array('label' = 'Project', 'options' = $projects)); echo $this-Form-input('description'); echo $this-Form-input('longitude'); echo $this-Form-input('latitude'); echo $this-Form-input('major', array('label' = 'Major Project')); //The num variable below is just used in the media attachments element so the controller can loop through the array, so just make sure you give each of the nums a sequential numerical order
Re: CakePHP (2.1) Media Plugin - Multi File Upload
Well this whole project has made me realise how much I suck at Ajax/JS etc. I ended up getting this working using cakephp's HTML5 multi file support and converting that data array to one that the media plugin would understand (as per Jeremy's first suggestion!). In case anybody else is looking to do this... In the view add to your form: echo $this-Form-input('files.', array('type' = 'file', 'multiple')); So that'll allow you to select multiple files. In the controller do something like: $i = 0; foreach ($this-request-data['Model']['files'] as $file) { $this-set($this-request-data['Photo'][$i]['model'] = 'Model'); $this-set($this-request-data['Photo'][$i]['group'] = 'group'); $this-set($this-request-data['Photo'][$i]['file'] = $this-request- data['Model']['files'][$i]); $i++; } Then make sure you have saveAll: if ($this-Model-saveAll($this-request-data)) { ... I'm going to spend some time sorting it out better and making it as reusable as possible. This solution is good for me as it's for an intranet site so I have control over what browser people are using. And if the users's browser doesn't support html5 then they can still upload, just one file at a time. Thanks for your suggestions Jeremy. On May 1, 11:27 pm, jeremyharris funeralm...@gmail.com wrote: I don't have any templates, but I use file-uploader[1] on a currently active project. It doesn't require jQuery but works pretty nicely. It sends each upload as a separate request, so write the controller code as if you're receiving one file (like the media plugin examples) and you should be good. This method is preferred, because when javascript is disabled the logic in the controller doesn't need to change will still work (i.e., old school single upload). 1:https://github.com/valums/file-uploader (doesn't seem to be maintained by the author but there are numerous forks) On Monday, April 30, 2012 8:09:33 PM UTC-7, double07 wrote: Hi Jeremy, Not having much luck with the saving manually option, do you having any working examples of drag and drop (jquery) I can look at? Thanks, -Brett On Apr 17, 7:44 am, jeremyharris funeralm...@gmail.com wrote: Or, instead of using the multiple option, you can try processing them each as a single request so you don't have to change anything in your controller but rather just how the view presents it. I've used drag and drop jQuery plugins and the like to help with this. It's by far my favorite solution, because it doesn't rely on browser specific features (such as HTML5 multiple upload). -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
I don't have any templates, but I use file-uploader[1] on a currently active project. It doesn't require jQuery but works pretty nicely. It sends each upload as a separate request, so write the controller code as if you're receiving one file (like the media plugin examples) and you should be good. This method is preferred, because when javascript is disabled the logic in the controller doesn't need to change will still work (i.e., old school single upload). 1: https://github.com/valums/file-uploader (doesn't seem to be maintained by the author but there are numerous forks) On Monday, April 30, 2012 8:09:33 PM UTC-7, double07 wrote: Hi Jeremy, Not having much luck with the saving manually option, do you having any working examples of drag and drop (jquery) I can look at? Thanks, -Brett On Apr 17, 7:44 am, jeremyharris funeralm...@gmail.com wrote: Or, instead of using the multiple option, you can try processing them each as a single request so you don't have to change anything in your controller but rather just how the view presents it. I've used drag and drop jQuery plugins and the like to help with this. It's by far my favorite solution, because it doesn't rely on browser specific features (such as HTML5 multiple upload). -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
Hi Jeremy, Not having much luck with the saving manually option, do you having any working examples of drag and drop (jquery) I can look at? Thanks, -Brett On Apr 17, 7:44 am, jeremyharris funeralm...@gmail.com wrote: Or, instead of using the multiple option, you can try processing them each as a single request so you don't have to change anything in your controller but rather just how the view presents it. I've used drag and drop jQuery plugins and the like to help with this. It's by far my favorite solution, because it doesn't rely on browser specific features (such as HTML5 multiple upload). -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
Sorry I never got notified of replies for some reason, I will try this looping method I think it could work. Thanks! On Apr 17, 7:44 am, jeremyharris funeralm...@gmail.com wrote: You could try looping through the files array and saving them manually: foreach $_FILES['files'] as $file { // create data array containing fields such as a foreignKey, model, etc. and save them as individual records } Or, instead of using the multiple option, you can try processing them each as a single request so you don't have to change anything in your controller but rather just how the view presents it. I've used drag and drop jQuery plugins and the like to help with this. It's by far my favorite solution, because it doesn't rely on browser specific features (such as HTML5 multiple upload). On Sunday, April 15, 2012 5:42:25 PM UTC-7, double07 wrote: Hi All, I'm using the cakephp media plugin in my project using the monolithic style attachments table, i.e. all the attachments go in the one table with foreign_key, model, group etc. saved with the file details. So my model looks like: class ProjectProfile extends AppModel { var $name = 'ProjectProfile'; var $useDbConfig = 'default'; var $useTable = 'project_profiles'; var $actsAs = array('Media.Transfer', 'Media.Generator'); public $belongsTo = array( 'Project' = array( 'className' = 'Project', 'foreignKey' = 'pjID' ) ); var $hasMany = array( 'Photo' = array( 'className' = 'Media.Attachment', 'order' = 'Photo.basename, Photo.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Photo.model' = 'ProjectProfile', 'Photo.group' = 'Photo'), 'dependent' = true) ); Then a saveAll in the controller when saving my record saves the attached file(s). This all works fine, however I'd really like to be able to upload multiple files at once, which the plugin does support by doing this in the form: echo $this-Form-hidden('Photo.0.model', array('value' = 'Photo')); echo $this-Form-input('Photo.0.file', array('type' = 'file'); echo $this-Form-hidden('Photo.1.model', array('value' = 'Photo')); echo $this-Form-input('Photo.1.file', array('type' = 'file'); echo $this-Form-hidden('Photo.2.model', array('value' = 'Photo')); echo $this-Form-input('Photo.2.file', array('type' = 'file'); But I think you'd agree that's a bit cumbersome to have to click browse for each individual file. The simplist method I could see to to allow multiple file uploads was to use the HTML5 multiple file section option - http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multip... : echo $this-Form-input('files.', array('type' = 'file', 'multiple')); This allows you to shift click in the file browser to select multiple files then puts the files into an array to save... however, this field format isn't handled by the media plugin. Also, there'd be no way to add the model, group etc. fields on the save as far as I could see. So, does anybody know how I can handle multi file uploads with the media plugin using the monolithic model? I'm open to all suggestions. Thanks in advance. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Cake Media Plugin: How to create dynamic directories
Great!!! Thanks Jeremy. James On Thursday, April 19, 2012 6:35:28 PM UTC-4, jeremyharris wrote: Yes, as defined in the transferTo function in your model. Here's a sample one that sticks it under a user directory and uses a UUID as the filename so there aren't conflicts (so something like /media/transfer/doc/user/550e8400-e29b-41d4-a716-44665544.doc): function transferTo($via, $from) { extract($from); $irregular = array( 'image' = 'img', 'text' = 'txt' ); $name = Mime_Type::guessName($mimeType ? $mimeType : $file); if (empty($extension)) { $extension = Mime_Type::guessExtension($mimeType ? $mimeType : $file); } if (isset($irregular[$name])) { $short = $irregular[$name]; } else { $short = substr($name, 0, 3); } $path = $short . DS; $path .= 'user' . DS; // make this as dynamic as you want $path .= String::uuid(); // uses a uuid as the doc name instead $path .= !empty($extension) ? '.' . strtolower($extension) : null; return $path; } This is defined on the model that $actsAs Media.Transfer. On Thursday, April 19, 2012 8:49:00 AM UTC-7, James Dcunha wrote: Hello all, With cake media plugin can we configure the plugin to create dynamic subdirectories dynamically inside the transfer folder without changing the plugin core code. Example with default settings I can transfer document files to WWW_ROOT/media/transfer/doc/test.doc Could we configure it to transfer document files to WWW_ROOT/media/transfer/doc/*{subdirectory}*/test.doc Regards James -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake Media Plugin: How to create dynamic directories
Hello all, With cake media plugin can we configure the plugin to create dynamic subdirectories dynamically inside the transfer folder without changing the plugin core code. Example with default settings I can transfer document files to WWW_ROOT/media/transfer/doc/test.doc Could we configure it to transfer document files to WWW_ROOT/media/transfer/doc/*{subdirectory}*/test.doc Regards James -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Cake Media Plugin: How to create dynamic directories
Yes, as defined in the transferTo function in your model. Here's a sample one that sticks it under a user directory and uses a UUID as the filename so there aren't conflicts (so something like /media/transfer/doc/user/550e8400-e29b-41d4-a716-44665544.doc): function transferTo($via, $from) { extract($from); $irregular = array( 'image' = 'img', 'text' = 'txt' ); $name = Mime_Type::guessName($mimeType ? $mimeType : $file); if (empty($extension)) { $extension = Mime_Type::guessExtension($mimeType ? $mimeType : $file); } if (isset($irregular[$name])) { $short = $irregular[$name]; } else { $short = substr($name, 0, 3); } $path = $short . DS; $path .= 'user' . DS; // make this as dynamic as you want $path .= String::uuid(); // uses a uuid as the doc name instead $path .= !empty($extension) ? '.' . strtolower($extension) : null; return $path; } This is defined on the model that $actsAs Media.Transfer. On Thursday, April 19, 2012 8:49:00 AM UTC-7, James Dcunha wrote: Hello all, With cake media plugin can we configure the plugin to create dynamic subdirectories dynamically inside the transfer folder without changing the plugin core code. Example with default settings I can transfer document files to WWW_ROOT/media/transfer/doc/test.doc Could we configure it to transfer document files to WWW_ROOT/media/transfer/doc/*{subdirectory}*/test.doc Regards James -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
Try MeioUpload. https://github.com/jrbasso/MeioUpload 2012/4/15 double07 br...@bluenectar.com.au Hi All, I'm using the cakephp media plugin in my project using the monolithic style attachments table, i.e. all the attachments go in the one table with foreign_key, model, group etc. saved with the file details. So my model looks like: class ProjectProfile extends AppModel { var $name = 'ProjectProfile'; var $useDbConfig = 'default'; var $useTable = 'project_profiles'; var $actsAs = array('Media.Transfer', 'Media.Generator'); public $belongsTo = array( 'Project' = array( 'className' = 'Project', 'foreignKey' = 'pjID' ) ); var $hasMany = array( 'Photo' = array( 'className' = 'Media.Attachment', 'order' = 'Photo.basename, Photo.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Photo.model' = 'ProjectProfile', 'Photo.group' = 'Photo'), 'dependent' = true) ); Then a saveAll in the controller when saving my record saves the attached file(s). This all works fine, however I'd really like to be able to upload multiple files at once, which the plugin does support by doing this in the form: echo $this-Form-hidden('Photo.0.model', array('value' = 'Photo')); echo $this-Form-input('Photo.0.file', array('type' = 'file'); echo $this-Form-hidden('Photo.1.model', array('value' = 'Photo')); echo $this-Form-input('Photo.1.file', array('type' = 'file'); echo $this-Form-hidden('Photo.2.model', array('value' = 'Photo')); echo $this-Form-input('Photo.2.file', array('type' = 'file'); But I think you'd agree that's a bit cumbersome to have to click browse for each individual file. The simplist method I could see to to allow multiple file uploads was to use the HTML5 multiple file section option - http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multiple_file_upload_with_cake : echo $this-Form-input('files.', array('type' = 'file', 'multiple')); This allows you to shift click in the file browser to select multiple files then puts the files into an array to save... however, this field format isn't handled by the media plugin. Also, there'd be no way to add the model, group etc. fields on the save as far as I could see. So, does anybody know how I can handle multi file uploads with the media plugin using the monolithic model? I'm open to all suggestions. Thanks in advance. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Paulo de Almeida Linux User #494076 Ubuntu User # 28289 In a world without walls who needs windows and gates? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP (2.1) Media Plugin - Multi File Upload
You could try looping through the files array and saving them manually: foreach $_FILES['files'] as $file { // create data array containing fields such as a foreignKey, model, etc. and save them as individual records } Or, instead of using the multiple option, you can try processing them each as a single request so you don't have to change anything in your controller but rather just how the view presents it. I've used drag and drop jQuery plugins and the like to help with this. It's by far my favorite solution, because it doesn't rely on browser specific features (such as HTML5 multiple upload). On Sunday, April 15, 2012 5:42:25 PM UTC-7, double07 wrote: Hi All, I'm using the cakephp media plugin in my project using the monolithic style attachments table, i.e. all the attachments go in the one table with foreign_key, model, group etc. saved with the file details. So my model looks like: class ProjectProfile extends AppModel { var $name = 'ProjectProfile'; var $useDbConfig = 'default'; var $useTable = 'project_profiles'; var $actsAs = array('Media.Transfer', 'Media.Generator'); public $belongsTo = array( 'Project' = array( 'className' = 'Project', 'foreignKey' = 'pjID' ) ); var $hasMany = array( 'Photo' = array( 'className' = 'Media.Attachment', 'order' = 'Photo.basename, Photo.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Photo.model' = 'ProjectProfile', 'Photo.group' = 'Photo'), 'dependent' = true) ); Then a saveAll in the controller when saving my record saves the attached file(s). This all works fine, however I'd really like to be able to upload multiple files at once, which the plugin does support by doing this in the form: echo $this-Form-hidden('Photo.0.model', array('value' = 'Photo')); echo $this-Form-input('Photo.0.file', array('type' = 'file'); echo $this-Form-hidden('Photo.1.model', array('value' = 'Photo')); echo $this-Form-input('Photo.1.file', array('type' = 'file'); echo $this-Form-hidden('Photo.2.model', array('value' = 'Photo')); echo $this-Form-input('Photo.2.file', array('type' = 'file'); But I think you'd agree that's a bit cumbersome to have to click browse for each individual file. The simplist method I could see to to allow multiple file uploads was to use the HTML5 multiple file section option - http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multiple_file_upload_with_cake : echo $this-Form-input('files.', array('type' = 'file', 'multiple')); This allows you to shift click in the file browser to select multiple files then puts the files into an array to save... however, this field format isn't handled by the media plugin. Also, there'd be no way to add the model, group etc. fields on the save as far as I could see. So, does anybody know how I can handle multi file uploads with the media plugin using the monolithic model? I'm open to all suggestions. Thanks in advance. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
CakePHP (2.1) Media Plugin - Multi File Upload
Hi All, I'm using the cakephp media plugin in my project using the monolithic style attachments table, i.e. all the attachments go in the one table with foreign_key, model, group etc. saved with the file details. So my model looks like: class ProjectProfile extends AppModel { var $name = 'ProjectProfile'; var $useDbConfig = 'default'; var $useTable = 'project_profiles'; var $actsAs = array('Media.Transfer', 'Media.Generator'); public $belongsTo = array( 'Project' = array( 'className' = 'Project', 'foreignKey' = 'pjID' ) ); var $hasMany = array( 'Photo' = array( 'className' = 'Media.Attachment', 'order' = 'Photo.basename, Photo.id', 'foreignKey' = 'foreign_key', 'conditions' = array('Photo.model' = 'ProjectProfile', 'Photo.group' = 'Photo'), 'dependent' = true) ); Then a saveAll in the controller when saving my record saves the attached file(s). This all works fine, however I'd really like to be able to upload multiple files at once, which the plugin does support by doing this in the form: echo $this-Form-hidden('Photo.0.model', array('value' = 'Photo')); echo $this-Form-input('Photo.0.file', array('type' = 'file'); echo $this-Form-hidden('Photo.1.model', array('value' = 'Photo')); echo $this-Form-input('Photo.1.file', array('type' = 'file'); echo $this-Form-hidden('Photo.2.model', array('value' = 'Photo')); echo $this-Form-input('Photo.2.file', array('type' = 'file'); But I think you'd agree that's a bit cumbersome to have to click browse for each individual file. The simplist method I could see to to allow multiple file uploads was to use the HTML5 multiple file section option - http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multiple_file_upload_with_cake : echo $this-Form-input('files.', array('type' = 'file', 'multiple')); This allows you to shift click in the file browser to select multiple files then puts the files into an array to save... however, this field format isn't handled by the media plugin. Also, there'd be no way to add the model, group etc. fields on the save as far as I could see. So, does anybody know how I can handle multi file uploads with the media plugin using the monolithic model? I'm open to all suggestions. Thanks in advance. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake Media Plugin: How to enable .docx files for upload and retrieve errors if upload fails
Hello all, I am using CakePHP 1.3 and Cake Media plugin (https://github.com/davidpersson/media). With the default setting I am able to upload images and pdf. I tried to upload a .docx file and I am not able to upload it. Following is the validate rule in my Document model ?php class Document extends AppModel { var $name = 'Document'; //media plugin behaviors var $actsAs = array( 'Media.Transfer', 'Media.Coupler', 'Media.Generator' ); var $validate = array( 'file' = array( 'mimeType' = array( 'rule' = array('checkMimeType', false, array ( 'text/plain','application/pdf', 'application/msword', 'application/rtf',' application/vnd.openxmlformats-officedocument.wordprocessingml.document')) ), 'size' = array( 'rule' = array('checkSize' , '120M') ) )); } I tried adding the extension values in my validate array but it did not work either. Let me know if I am missing something. Another question how do I retrieve the errors for failing to upload from the media plugin in my controller. Would $errors = $this-Document-invalidFields(); work? Regards James -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin begginer problems....
Hi, I'm trying to use David Person's Media Plugin with an hasMany association and it doesn't work... My environment: - Win XP - CakePHP 1.3.14 - PHP 5.3.8 - Media Plugin 1.3 Media plugin is in my App/plugins directory. In my config/boostrap.php, I have: require APP.'plugins/media/config/core.php I've created a model called Attachment, with a database table attachmentes defined like that: ID model foreign_key dirname basename checksum alternative group created modified In Attachement Model, I've defined the behavior like that: public $actsAs = array('Media.Transfer','Media.Coupler'). In a Apartment Model, I've defined an hasMany association like that: public $hasMany = array('Photo' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'dependent' = true, 'conditions' = array('Photo.model' = 'Apartment'), )); In a Apartment edit view I've my form defined like that: ?php echo $this-Form-create('Apartment',array('type'='file','action'='edit_photos')); ? ?php echo $this-Form-input('Apartment.id'); ? ?php echo $this-Form-hidden('Attachment.0.model',array('value'='Apartment')); ? ?php echo $this-Form-end(__('Save',true)); ? And finally, in my edit_photos method, I make a saveAll() like that: $this-Apartment-saveAll($this-data, array('validate' = 'first')); When I submit a valid file (a real jpg image), the saveAll return true, but no file is uploaded in webroot/media/transfer/img directory and there is no record saved in my attachments table... I've tried to define an belongsTo association with Apartment in Attachment model, no success. I've tried to just using Media.Tranfer, no success. What I miss?! thanks by advance for any help. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
MD5 file warning with Media Plugin
Hi there, I am trying to use the Media plugin for Cake 2.0 (https://github.com/ bmcclure/CakePHP-Media-Plugin) and all appears to be working except that I am getting the warning below on 2 of my view pages. I have searched high and low for answers, but am not finding anything. Warning (2): md5_file(C:\xampp\htdocs\client\v4\app\webroot\media\) [function.md5-file]: failed to open stream: No such file or directory [CORE\Cake\Utility\File.php, line 374] Has anyone else used this plugin and if so, has anyone ever experienced this issue? Any advice or help will be much appreciated. Thanks in advance, Nikki -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: MD5 file warning with Media Plugin
On Thursday, 1 March 2012 11:07:34 UTC+1, Nif wrote: Hi there, I am trying to use the Media plugin for Cake 2.0 (https://github.com/ bmcclure/CakePHP-Media-Pluginhttps://github.com/bmcclure/CakePHP-Media-Plugin) and all appears to be working except that I am getting the warning below on 2 of my view pages. I have searched high and low for answers, but am not finding anything. Warning (2): md5_file(C:\xampp\htdocs\client\v4\app\webroot\media\) [function.md5-file]: failed to open stream: No such file or directory [CORE\Cake\Utility\File.php, line 374] On Thursday, 1 March 2012 11:07:34 UTC+1, Nif wrote: Hi there, I am trying to use the Media plugin for Cake 2.0 (https://github.com/ bmcclure/CakePHP-Media-Pluginhttps://github.com/bmcclure/CakePHP-Media-Plugin) and all appears to be working except that I am getting the warning below on 2 of my view pages. I have searched high and low for answers, but am not finding anything. Warning (2): md5_file(C:\xampp\htdocs\client\v4\app\webroot\media\) [function.md5-file]: failed to open stream: No such file or directory [CORE\Cake\Utility\File.php, line 374] Has anyone else used this plugin and if so, has anyone ever experienced this issue? Any advice or help will be much appreciated. Debug why you are passing a folder path to md5_file. AD -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
support regarding cakephp 2.0 media plugin
hi, Im a beginner and asked to do a form for batch upload of images and so I'm trying hard to understand the concept, i found few online and all were pretty old, means they were cakephp 1.3. I would be very thankful, if any one could help me with a detailed tutorial on batch upload of images. Regards Thanks Dhanush -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media PLugin
I probably didn't take your reply the right way. Hopefully I wasn't too harsh myself. Anyway, hopefully you'll get a response from David soon. Did you ever get to try out passing an empty 'file' key in the form (i.e., a hidden field)? That way, the key would exist and the Coupler wouldn't unset the data. I don't think this is a very elegant solution either, but I was curious if you tried it out. On Tuesday, February 28, 2012 8:41:39 PM UTC-8, Jeremy Burns wrote: Gosh my reply sounded harsh on you Jeremy - that wasn't my intention. We've commented out the line that unsets the data and it *all seems fine*, which also feels dirty. The user records are saving correctly, we can subsequently add images to user records and all other dedicated image tables that use the coupler are functioning too. I did reach out to David yesterday, hoping to learn more from him so that we can implement this properly and will report back. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 21:15:25, jeremyharris wrote: I didn't say I agreed with how it worked, I was just explaining what I think the author's intended use case was. The question was if you were missing a setting or doing anything wrong. You weren't, so I just threw out some ideas based on how the Coupler works. Feel free to take it up with the author or create a Coupler that works for you. I'm glad that an empty image doesn't create garbage data, that thought was based off of what the Coupler does down the road (check the file and populate dirname and basename). On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data
Re: Media PLugin
I tried it earlier by adding the following to the end of the beforeSave() in our Users model: if (!isset($this-data['User']['file'])) { $this-data['User']['file'] = null; } But when I tested it I discovered that the beforeSave() in the Media Coupler was firing before the beforeSave() in our Users model, so it was too late to add the empty 'file' key to the array as the 'User' had already been unset by the Coupler. I've therefore had to roll the change back and go back to the drawing board for now. Keith Gorman Class Outfit keithgor...@classoutfit.com www.classoutfit.com On 29 Feb 2012, at 15:21, jeremyharris wrote: I probably didn't take your reply the right way. Hopefully I wasn't too harsh myself. Anyway, hopefully you'll get a response from David soon. Did you ever get to try out passing an empty 'file' key in the form (i.e., a hidden field)? That way, the key would exist and the Coupler wouldn't unset the data. I don't think this is a very elegant solution either, but I was curious if you tried it out. On Tuesday, February 28, 2012 8:41:39 PM UTC-8, Jeremy Burns wrote: Gosh my reply sounded harsh on you Jeremy - that wasn't my intention. We've commented out the line that unsets the data and it *all seems fine*, which also feels dirty. The user records are saving correctly, we can subsequently add images to user records and all other dedicated image tables that use the coupler are functioning too. I did reach out to David yesterday, hoping to learn more from him so that we can implement this properly and will report back. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 21:15:25, jeremyharris wrote: I didn't say I agreed with how it worked, I was just explaining what I think the author's intended use case was. The question was if you were missing a setting or doing anything wrong. You weren't, so I just threw out some ideas based on how the Coupler works. Feel free to take it up with the author or create a Coupler that works for you. I'm glad that an empty image doesn't create garbage data, that thought was based off of what the Coupler does down the road (check the file and populate dirname and basename). On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video
Re: Media PLugin
What about setting an empty hidden field in the view, like echo $this-Form-hidden('Model.file', array('value' = '')); I'd probably be more prone to just copy and paste the Coupler to my own behaviors and modify it, or create a new small behavior that is just dedicated to this task. On Wednesday, February 29, 2012 7:49:01 AM UTC-8, keith...@classoutfit.com wrote: I tried it earlier by adding the following to the end of the beforeSave() in our Users model: if (!isset($this-data['User']['file'])) { $this-data['User']['file'] = null; } But when I tested it I discovered that the beforeSave() in the Media Coupler was firing before the beforeSave() in our Users model, so it was too late to add the empty 'file' key to the array as the 'User' had already been unset by the Coupler. I've therefore had to roll the change back and go back to the drawing board for now. Keith Gorman *Class Outfit* ** keithgor...@classoutfit.com www.classoutfit.com On 29 Feb 2012, at 15:21, jeremyharris wrote: I probably didn't take your reply the right way. Hopefully I wasn't too harsh myself. Anyway, hopefully you'll get a response from David soon. Did you ever get to try out passing an empty 'file' key in the form (i.e., a hidden field)? That way, the key would exist and the Coupler wouldn't unset the data. I don't think this is a very elegant solution either, but I was curious if you tried it out. On Tuesday, February 28, 2012 8:41:39 PM UTC-8, Jeremy Burns wrote: Gosh my reply sounded harsh on you Jeremy - that wasn't my intention. We've commented out the line that unsets the data and it *all seems fine*, which also feels dirty. The user records are saving correctly, we can subsequently add images to user records and all other dedicated image tables that use the coupler are functioning too. I did reach out to David yesterday, hoping to learn more from him so that we can implement this properly and will report back. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 21:15:25, jeremyharris wrote: I didn't say I agreed with how it worked, I was just explaining what I think the author's intended use case was. The question was if you were missing a setting or doing anything wrong. You weren't, so I just threw out some ideas based on how the Coupler works. Feel free to take it up with the author or create a Coupler that works for you. I'm glad that an empty image doesn't create garbage data, that thought was based off of what the Coupler does down the road (check the file and populate dirname and basename). On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else
Re: Media Plugin - Getting Started
Hi to all, I'm trying to handle with video files, but with no luck. I'm working on this stuff var $validate = array( 'file' = array( 'resource' = array('rule' = 'checkResource'), 'access' = array('rule' = 'checkAccess'), 'location' = array('rule' = array('checkLocation', array( MEDIA_TRANSFER, '/tmp/' ))), 'extension' = array('rule' = array('checkExtension', false, array( 'jpg', 'jpeg', 'png', 'tif', 'tiff', 'gif', 'pdf', 'tmp','avi','mpeg' ))), 'mimeType' = array('rule' = array('checkMimeType', false, array( 'image/jpeg', 'image/png', 'image/tiff', 'image/gif', 'application/pdf','video/x-msvideo','video/vnd.mpegurl','video/mpeg' ); Il giorno mercoledì 7 luglio 2010 04:26:16 UTC+2, dbme ha scritto: Awesome! So what is your directory structure (step 3)? Is it app/webroot/media/static/ app/webroot/media/filter/ app/transfer/ OR app/webroot/media/static/ app/webroot/media/filter/ app/webroot/media/transfer/ Also, did the styles still get served properly after step 5 (protecting the transfer directory)? I would love to see how you made it work! Would you mind posting an example or emailing me the relevant code? If I can get it working I think it would be great to add this as a full-on tutorial in the wiki. Thank you!! On Jul 6, 6:11 pm, randy ran...@gmail.com wrote: So glad to see someone else is taking a crack at this... Thanks to your post i was able to make a bit of headway...when i set this up the first time I had troubles with getting things right in my bootstrap.php file. However, i had a fairly easy time with other parts of this, namely the actual file-upload and metadata fields. I just set this up again using your instructions for bootstrap.php, and with just a few more adjustments I have it uploading files to the transfer directory and spitting out copies of the original, in different sizes. There are just two more things that I want to get working...I'd like to use the Media Helper to pull in my uploaded images, and, most importantly, I'd like to get the file-renaming functionality working so that users don't overwrite each others files. This also makes it tough to guess filenames if people go fishing for the uploaded images. I am running this on a cake 1.3 setup in case anyone was wondering. On Jul 5, 1:30 pm, dbme boston.dus...@gmail.com wrote: I'm just getting started with CakePHP and also David Persson's Media plugin (http://github.com/davidpersson/media). I've got my app working but I'm having a difficult time getting the Media plugin working. I figured I'd start this thread so I could A.) get it working and B.) create a reference for beginners like me. Here's what I've done so far (following the README and Configuration wiki -http://wiki.github.com/davidpersson/media/configuration). Steps marked with a * didn't go as documented :( 1. Download and extract the files to /path/to/your/app/plugins/media 2. Include the Media plugin config file in the /path/to/your/app/ config/bootstrap.php define ( 'MEDIA_TRANSFER', APP . 'transfer' . DS); define ( 'MEDIA_TRANSFER_URL', false); require APP . 'plugins/media/config/core.php'; * 3. Create the directory structure using the console cd /path/to/your/app/ ../cake/console/cake media init The Configuration wiki says that there should be a static, filter, and transfer directory under the webroot/media/ directory but the command above will put the transfer directory under the app directory. Not sure if this is how it should be or if I did something wrong. * 4. Copy/move/collect the media into the new location ../cake/console/cake media collect But this results in a bunch of errors :( --- - Media Shell --- - PHP Warning: Invalid argument supplied for foreach() in /path/to/your/ app/plugins/media/vendors/shells/tasks/collect.php on line 119 Warning: Invalid argument supplied for foreach() in /path/to/your/app/ plugins/media/vendors/shells/tasks/collect.php on line 119 PHP Notice: Undefined variable: pluginVendorPaths in /var/www/ portfolio/app/plugins/media/vendors/shells/tasks/collect.php on line 130 Notice: Undefined variable: pluginVendorPaths in /path/to/your/app/ plugins/media/vendors/shells/tasks/collect.php on line 130 PHP Warning: array_merge(): Argument #1 is not an array in /path/to/ your/app/plugins/media/vendors/shells/tasks/collect.php on line 130 Warning: array_merge(): Argument #1 is not an array in /path/to/your/ app/plugins/media/vendors/shells/tasks/collect.php on line 130 PHP Warning: Invalid argument supplied for foreach
Media PLugin
I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media PLugin
It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media PLugin
I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media PLugin
I didn't say I agreed with how it worked, I was just explaining what I think the author's intended use case was. The question was if you were missing a setting or doing anything wrong. You weren't, so I just threw out some ideas based on how the Coupler works. Feel free to take it up with the author or create a Coupler that works for you. I'm glad that an empty image doesn't create garbage data, that thought was based off of what the Coupler does down the road (check the file and populate dirname and basename). On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist
Re: Media PLugin
Gosh my reply sounded harsh on you Jeremy - that wasn't my intention. We've commented out the line that unsets the data and it *all seems fine*, which also feels dirty. The user records are saving correctly, we can subsequently add images to user records and all other dedicated image tables that use the coupler are functioning too. I did reach out to David yesterday, hoping to learn more from him so that we can implement this properly and will report back. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 21:15:25, jeremyharris wrote: I didn't say I agreed with how it worked, I was just explaining what I think the author's intended use case was. The question was if you were missing a setting or doing anything wrong. You weren't, so I just threw out some ideas based on how the Coupler works. Feel free to take it up with the author or create a Coupler that works for you. I'm glad that an empty image doesn't create garbage data, that thought was based off of what the Coupler does down the road (check the file and populate dirname and basename). On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you are updating, you shouldn't *need* the 'file' key. That said, you can probably get away with passing an empty (or a path to a default image) file key when you are creating the User using a hidden field. This should allow the coupler to continue with the save. This may save some empty garbage data that is probably unwanted. The other solution would be to detach the Coupler behavior at runtime when you don't want it to force you to have an image. The whole point of the Coupler is to tightly couple the physical image to the record, so if the image doesn't exist neither should the record. I tend to create a separate table for attachments for this very reason. A user should be allowed to exist without an image. On Tuesday, February 28, 2012 5:42:11 AM UTC-8, Jeremy Burns wrote: I'm using David Persson's media plugin. I have a users table that contains the fields necessary to link to an image file, but a user does not have to have an image. When I include the Media.Coupler behaviour in the User model User-create always fails on User-save when the user does not have an image because of the beforeSave in coupler.php: function beforeSave($Model) { if (!$Model-exists()) { if (!isset($Model-data[$Model-alias]['file'])) { unset($Model-data[$Model-alias]); --- clears down my User data return true; } } else { This is unsetting the User data because the file key is missing. If I comment out the unset my User-save is successful. The Media.Coupler is working perfectly well for another table that hasMany images in an associated table. Is there a setting I need to configure or am I doing something else wrong? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php On Tuesday, February 28, 2012 12:06:23 PM UTC-8, Jeremy Burns wrote: I understand what you are saying but I don't think it's the full answer. It's a perfectly valid use case to have a table that has an optional image in it without the need to have a separate join table. The absence of the image doesn't create any garbage data; the user row is still valid. A bio snap for a user is good example. For the plugin to simply clear the whole data array because the optional image fields aren't populated is nuts. If the fields are empty simply return true and let the main model get on with its work. Jeremy Burns Class Outfit http://www.classoutfit.com On 28 Feb 2012, at 15:45:29, jeremyharris wrote: It should only unset the data if you are creating the User and it's missing the 'file' key. If you
Re: Media Plugin of David Persson is for cake 1.3 and for cake 2.0?
Have you tried this plugin: https://github.com/josegonzalez/upload/tree/2.0 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin of David Persson is for cake 1.3 and for cake 2.0?
Hi I would open a discussion between all developers that use cakephp. I think that a frequent problem in development is the File Upload. For Cake 1.3 exists the fantastic Media Plugin of David Persson that for me is it the best plugin about File Upload. But Media Plugin of David Persson hasn't a version for Cake 2.0. My question is : Which is the best plugin to use in Cake 2.0 to manage File Upload? Many Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media Plugin of David Persson is for cake 1.3 and for cake 2.0?
It may be an idea to make changes to the media plugin for 2.x and share it if lisences arent an issue. I'm still on 1.3 for now but it would be nice to contribute. Sent from my iPhone On 22 Feb 2012, at 17:01, byqsri marco.rizze...@gmail.com wrote: Hi I would open a discussion between all developers that use cakephp. I think that a frequent problem in development is the File Upload. For Cake 1.3 exists the fantastic Media Plugin of David Persson that for me is it the best plugin about File Upload. But Media Plugin of David Persson hasn't a version for Cake 2.0. My question is : Which is the best plugin to use in Cake 2.0 to manage File Upload? Many Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media Plugin of David Persson is for cake 1.3 and for cake 2.0?
See: https://github.com/davidpersson/media/issues/66 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin on IIS 7
I am trying to get the plugin to work on IIS 7. I have set the correct permissions to the media folder under webroot. However I am getting a 404 when i try to access uploaded images. Server logs show a 200 status. I am a newbie to cake and media plugin. Could somebody tell me what the problem could be. thank you. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin on IIS 7
If you used the media shell to protect your files, it *could* be why. Check for an .htaccess file under /webroot/media. If not, we'll need more information. Can you get to them locally? Did you check to make sure they are uploaded correctly? Were the permissions you set recursive? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin on IIS 7
Hi Jeremy, Thank you very much for you reply. I have not protected the media folders (no htaccess in media folder). Also Godaddy is the hosting provider and I am tied to IIS. I had already removed 'recursive permissions' from parent for the media, transfer and filter folder (and subfolders) and checked. 404 persists (even though I see a 200 in the IIS logs). I am unable to think further. Really need help here. Thanks very much again. regards, John On Feb 6, 8:15 pm, jeremyharris funeralm...@gmail.com wrote: If you used the media shell to protect your files, it *could* be why. Check for an .htaccess file under /webroot/media. If not, we'll need more information. Can you get to them locally? Did you check to make sure they are uploaded correctly? Were the permissions you set recursive? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin on IIS 7
If the 404 isn't being sent by the server, it's probably being sent by Cake. Turn on debug to see what errors cake generates, or look at the debug log (/tmp/logs/debug.log). Any clues in there? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin on IIS 7
Hi Jeremy, Nothing in the app debug logs. However I looked at the IIS server logs. All requests to the uploaded images are being routed through index.php. I have used the rewrite rules from here - http://book.cakephp.org/1.3/view/1636/URL-Rewrites-on-IIS7-Windows-hosts I am not sure if I understand this right but I think that based on 'Redirect static resources' rule requests to images must just pass through. However I see that they are going through index.php. Here's the web.config - ?xml version=1.0 encoding=UTF-8? configuration system.webServer rewrite rules rule name=Redirect static resources stopProcessing=true match url=^(ico|img|css|files|js)(.*)$/ action type=Rewrite url=app/webroot/{R:1}{R:2} appendQueryString=false/ /rule rule name=Imported Rule 1 stopProcessing=true match url=^(.*)$ ignoreCase=false/ conditions logicalGrouping=MatchAll add input={REQUEST_FILENAME} matchType=IsDirectory negate=true/ add input={REQUEST_FILENAME} matchType=IsFile negate=true/ /conditions action type=Rewrite url=index.php?url={R:1} appendQueryString=true/ /rule rule name=Imported Rule 2 stopProcessing=true match url=^$ ignoreCase=false/ action type=Rewrite url=// /rule rule name=Imported Rule 3 stopProcessing=true match url=(.*) ignoreCase=false/ action type=Rewrite url=/{R:1}/ /rule rule name=Imported Rule 4 stopProcessing=true match url=^(.*)$ ignoreCase=false/ conditions logicalGrouping=MatchAll add input={REQUEST_FILENAME} matchType=IsDirectory negate=true/ add input={REQUEST_FILENAME} matchType=IsFile negate=true/ /conditions action type=Rewrite url=index.php?url={R:1} appendQueryString=true/ /rule /rules /rewrite !--urlCompression doStaticCompression=false/-- /system.webServer /configuration Please do let me know if there is any change I must make in this file. thanks again very much. regards, John -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
CakePHP Media Plugin of David Persson and CDN
Hi I use the fantastic Media Plugin of David Persson. For now I have all my uploaded files in the same server I would ask if someone uses this plugin with some CDN and how use it with CDN? Many Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP Media Plugin of David Persson and CDN
Add a behavior that has an afterSave and afterDelete that take care of it (or attach those actions to your model). Here's a helper function to get a list of files based on your filters set (hardcoded for images, but you can adapt it to use whatever types you want). Once you have that list of files, you can move them to your CDN or remove them if they were deleted. function _getFiles($model, $id = null) { if (!$id) { return array(); } $result = $model-read(null, $id); // get all including filtered $files = array(); $files[] = array( 'path' = $result[$model-alias]['file'], 'url' = MEDIA_TRANSFER_URL . $result[$model-alias]['dirname'] . '/' . $result[$model-alias]['basename'] ); $extension = Mime_Type::guessExtension($files[0]['path']); $filters = Configure::read('Media.filter.image'); foreach ($filters as $size = $filter) { if (isset($filter['convert'])) { $newextension = Mime_Type::guessExtension($filter['convert']); } else { $newextension = $extension; } $newbasename = str_replace($extension, $newextension, $result[$model-alias]['basename']); $path = MEDIA_FILTER . $size . DS . $result[$model-alias]['dirname'] . DS . $newbasename; $url = MEDIA_FILTER_URL . $size . '/' . $result[$model-alias]['dirname'] . '/'. $newbasename; $files[] = compact('path', 'url'); } return $files; } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
CakePHP Media Plugin quality of image
Hi I'm using Media Plugin of David Persson (https://github.com/ davidpersson/media) and it is very very useful. I would ask a question that I can't resolve. My question is that when I do a filtering (fitInside) of an upload image Configure::write('Media.filter.image', array( 's' = array('convert' = 'image/jpeg', 'fitInside' = array(124, 81)) ) ); I note that the quality of the filtered image is not good I would ask if there is a method to improve the quality. Many Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin - Batch Image Upload
Whithout flash, you can use jQuery fileuploader plugin : http://pixelcone.com/tutorial/ajax-file-upload-using-jquery-and-cakephp-media-plugin/ On 9 nov, 07:28, Shinya Koizumi sh.koiz...@gmail.com wrote: I wouldn't use flash ( I just can't ignore iOS ) , but I would use this onehttp://valums.com/ajax-upload/ On Tue, Nov 8, 2011 at 9:25 PM, Greg Skerman gsker...@gmail.com wrote: to upload multiple files, there is a flash gadget which can be used called SWFUpload here is a demo showing a classic multi-select file browser: http://demo.swfupload.org/v220/formsdemo/index.php Its not a complete media plugin, you'll need to either write a back end or massage an existing back end into service. On Wed, Nov 9, 2011 at 5:10 AM, BigZee ad...@2ndrevolt.com wrote: I have been using the media plugin for quite some time on multiple sites. I absolutely love it and it has always worked well for any application I might need it on. However I have run into a situation and would like to use this plugin, but cannot seem to find any resources concerning this. I did find one post that said it was possible, but that was about all. So I'm working on an auction site and the user needs to be able to upload, say 50, images per auction. I'm sure given a single field upload you could see how big of a pain this would be. So what I would like to know, is there a way that the Media plugin can handle batch uploading of multiple images at once? Thx... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin - Batch Image Upload
I have been using the media plugin for quite some time on multiple sites. I absolutely love it and it has always worked well for any application I might need it on. However I have run into a situation and would like to use this plugin, but cannot seem to find any resources concerning this. I did find one post that said it was possible, but that was about all. So I'm working on an auction site and the user needs to be able to upload, say 50, images per auction. I'm sure given a single field upload you could see how big of a pain this would be. So what I would like to know, is there a way that the Media plugin can handle batch uploading of multiple images at once? Thx... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin - Batch Image Upload
to upload multiple files, there is a flash gadget which can be used called SWFUpload here is a demo showing a classic multi-select file browser: http://demo.swfupload.org/v220/formsdemo/index.php Its not a complete media plugin, you'll need to either write a back end or massage an existing back end into service. On Wed, Nov 9, 2011 at 5:10 AM, BigZee ad...@2ndrevolt.com wrote: I have been using the media plugin for quite some time on multiple sites. I absolutely love it and it has always worked well for any application I might need it on. However I have run into a situation and would like to use this plugin, but cannot seem to find any resources concerning this. I did find one post that said it was possible, but that was about all. So I'm working on an auction site and the user needs to be able to upload, say 50, images per auction. I'm sure given a single field upload you could see how big of a pain this would be. So what I would like to know, is there a way that the Media plugin can handle batch uploading of multiple images at once? Thx... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin - Batch Image Upload
I wouldn't use flash ( I just can't ignore iOS ) , but I would use this one http://valums.com/ajax-upload/ On Tue, Nov 8, 2011 at 9:25 PM, Greg Skerman gsker...@gmail.com wrote: to upload multiple files, there is a flash gadget which can be used called SWFUpload here is a demo showing a classic multi-select file browser: http://demo.swfupload.org/v220/formsdemo/index.php Its not a complete media plugin, you'll need to either write a back end or massage an existing back end into service. On Wed, Nov 9, 2011 at 5:10 AM, BigZee ad...@2ndrevolt.com wrote: I have been using the media plugin for quite some time on multiple sites. I absolutely love it and it has always worked well for any application I might need it on. However I have run into a situation and would like to use this plugin, but cannot seem to find any resources concerning this. I did find one post that said it was possible, but that was about all. So I'm working on an auction site and the user needs to be able to upload, say 50, images per auction. I'm sure given a single field upload you could see how big of a pain this would be. So what I would like to know, is there a way that the Media plugin can handle batch uploading of multiple images at once? Thx... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Plupload and Media Plugin
Hey thanksfor your reply. I might not have expressed myself clearly enough (sorry). My problem is using a standard html form upload field leads to a browser timeout (javascript to keep it alive?). also some kind of visual feedback would be great to ensure the user the upload is still being processed. I hope it became clearer what my problem is. I played a bit with uploadify yesterday but I'm not convinced by the use of flash. Better ideas? On Nov 7, 6:20 am, Zaky Katalan-Ezra procsh...@gmail.com wrote: it is not ideal to handle big uploads Why is that? What is your problem? I am using the plugin and have no problems with large files. Did you set php properly? http://www.radinks.com/upload/config.php On Sun, Nov 6, 2011 at 7:43 PM, Mo moritz.stoessl...@googlemail.com wrote: Hey I need the ability to upload large (up to 100MB) files. Up to now I have the David Persson's Media Plugin integrated however it is not ideal to handle big uploads. Is there a way to integrate Pulpload (or something similar) to work with the Media plugin and Cakephp? Has anyone of you done this already? Regards -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Regards, Zaky Katalan-Ezra QA Administratorwww.IGeneriX.com Sites.IGeneriX.com054-7762312 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Plupload and Media Plugin
Hey I need the ability to upload large (up to 100MB) files. Up to now I have the David Persson's Media Plugin integrated however it is not ideal to handle big uploads. Is there a way to integrate Pulpload (or something similar) to work with the Media plugin and Cakephp? Has anyone of you done this already? Regards -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Plupload and Media Plugin
it is not ideal to handle big uploads Why is that? What is your problem? I am using the plugin and have no problems with large files. Did you set php properly? http://www.radinks.com/upload/config.php On Sun, Nov 6, 2011 at 7:43 PM, Mo moritz.stoessl...@googlemail.com wrote: Hey I need the ability to upload large (up to 100MB) files. Up to now I have the David Persson's Media Plugin integrated however it is not ideal to handle big uploads. Is there a way to integrate Pulpload (or something similar) to work with the Media plugin and Cakephp? Has anyone of you done this already? Regards -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Regards, Zaky Katalan-Ezra QA Administrator www.IGeneriX.com Sites.IGeneriX.com 054-7762312 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Can't Get Media Plugin to Work with Nested Models
I have been using the Media Plugin by David Persson and I think it's great and has saved me a lot of time. I started out with an Invoice model that hasMany Attachments and everything worked well. I then added Materials to my invoice and tried added Attachments to a specific material associated with the Invoice. The extra attachment is read at the server and saved, but it is saved with the invoice_id, not the specific material item on that invoice. Here is my data array as it arrives at the server, via my iPhone app. [Invoice] = Array ( [project_id] = 2 [invoice_date] = 2011/10/01 [is_approved] = 1 ) [InvoicedMaterial] = Array ( [0] = Array ( [description] = Diesel Fuel [amount] = 20 [unit_of_measure] = Gallons ) ) [Attachment] = Array ( [0] = Array ( [model] = InvoicedMaterial [alternative] = Diesel Fuel [file] = Array ( [name] = Diesel Fuel [type] = image/jpeg [tmp_name] = /tmp/phpP7Qy7k [error] = 0 [size] = 901352 ) ) [1] = Array ( [model] = Invoice [alternative] = Signature [file] = Array ( [name] = 023C1C3D-B63F-442E-87DE- FC3D270D8740 [type] = image/png [tmp_name] = /tmp/phpkhczsG [error] = 0 [size] = 5953 ) ) ) [InvoicedLabor] = Array ( [0] = Array ( [description] = Construction Foreman [amount] = 10 [unit_of_measure] = hrs ) ) ) My models are setup as follows: Invoice: var $hasMany = array( 'InvoicedEquipment' = array( 'className' = 'InvoicedEquipment', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'InvoicedLabor' = array( 'className' = 'InvoicedLabor', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'InvoicedMaterial' = array( 'className' = 'InvoicedMaterial', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'Invoice'), 'dependent' = true, ) ); InvoicedMaterial: var $hasMany = array( 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'InvoicedMaterial'), 'dependent' = true, )); I'm passing all of the attachments as one array, based on the plugin recipes documentation, but that doesn't seem right. Can the media plugin handle a nested form being posted and figure out which attachment should be associated with which model? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Having Trouble with Media Plugin and a Nested Model HTTP Post
I have been using the Media Plugin by David Persson and I think it's great and has saved me a lot of time. I started out with an Invoice model that hasMany Attachments and everything worked well. I then added Materials to my invoice and tried added Attachments to a specific material associated with the Invoice. The extra attachment is read at the server and saved, but it is saved with the invoice_id, not the specific material item on that invoice. Here is my data array as it arrives at the server, via my iPhone app. [Invoice] = Array ( [project_id] = 2 [invoice_date] = 2011/10/01 [is_approved] = 1 ) [InvoicedMaterial] = Array ( [0] = Array ( [description] = Diesel Fuel [amount] = 20 [unit_of_measure] = Gallons ) ) [Attachment] = Array ( [0] = Array ( [model] = InvoicedMaterial [alternative] = Diesel Fuel [file] = Array ( [name] = Diesel Fuel [type] = image/jpeg [tmp_name] = /tmp/phpP7Qy7k [error] = 0 [size] = 901352 ) ) [1] = Array ( [model] = Invoice [alternative] = Signature [file] = Array ( [name] = 023C1C3D-B63F-442E-87DE- FC3D270D8740 [type] = image/png [tmp_name] = /tmp/phpkhczsG [error] = 0 [size] = 5953 ) ) ) [InvoicedLabor] = Array ( [0] = Array ( [description] = Construction Foreman [amount] = 10 [unit_of_measure] = hrs ) ) ) My models are setup as follows: Invoice: var $hasMany = array( 'InvoicedEquipment' = array( 'className' = 'InvoicedEquipment', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'InvoicedLabor' = array( 'className' = 'InvoicedLabor', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'InvoicedMaterial' = array( 'className' = 'InvoicedMaterial', 'foreignKey' = 'invoice_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'Invoice'), 'dependent' = true, ) ); InvoicedMaterial: var $hasMany = array( 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'InvoicedMaterial'), 'dependent' = true, )); I'm passing all of the attachments as one array, based on the plugin recipes documentation, but that doesn't seem right. Can the media plugin handle a nested form being posted and figure out which attachment should be associated with which model? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin - data to different database fields
Hello, I just installed David Persson Media Plugin to use it with Ajax uploader. The tutorial from here: http://pixelcone.com/tutorial/ajax-file-upload-using-jquery-and-cakephp-media-plugin/ But my database have different field names. And I would like to save some more information, not only the dirname and basename. How to view what other information about the uploaded file i can save into the database and how to change the field names in which the information is written. Because of using ajax uploader i dont know how to pr($this-data) when uploading the file. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Perssons Media Plugin - does it work at all on windows
Hi there, I'm new to cakephp and trying to install Media Plugin in my test app. By all accounts media plugin is the best plugin of it's kind, the problem I have is I'm developing on my localhost on a windows machine. I get stuck when I get to doing the: cake media init chmod -R a+rwX app/webroot/media/{transfar,filter} Where I just get an error: php fatal error: call to undefined method MIME_Type::config() Now, when I did some googling I discovered that there are quite a number of possible issues with windows. I'm only wanting to upload a photo and save a couple of sizes of it. Nothing too complex. But I'm worried about knocking something together myself because (a) I don't know enuf probably (b) at least with media plugin I know there's validation and best practice etc etc. My questions are: what exactly are the problems with it and windows (I've seen the big list but it means nothing to me) or at least, will they affect me with what I want to do? I'm not completely sure but I think that chmod thing I typed into the console above makes a couple of folders and sets permissions, can anyone tell me in english the manual way to do this so I can by pass the error I was getting Any help would be gratefully received :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin and user plugin
It would be mch better if you tried to debug why it is causing the user record not to save. My questions where the first steps in trying to do that. HTH, Paul @phpMagpie On Sep 17, 6:51 pm, Zaky Katalan-Ezra procsh...@gmail.com wrote: I didn't change register action at all. I just added the Media behaviors to user model $actsAs. Its working perfectly in other controllers. Anyway I found a solution: I needed the media plugin in order to upload the user profile image. I removed the 'Media.Coupler' from the user model $actsAs and add this code at user controller upload_image action: public function upload_image() { $this-User-Behaviors-attach('Media.Coupler'); ... ... $this-User-Behaviors-detach('Media.Coupler'); $this-redirect($this-referer()); } But it means that I can't add image_file field to registration form. After the user registered and verified his account he should enter his profile page and add an image. I should try using the media plugin on a clean solution to decide where is the problem On Fri, Sep 16, 2011 at 12:34 PM, WebbedIT p...@webbedit.co.uk wrote: More information required ... - have you echoed $this-data on submit to see what data there is - how are you calling save in the controller? - have you looked at the sql dump to see what Cake is trying? HTH, Paul @phpMagpie On Sep 15, 11:11 am, ZAky procsh...@gmail.com wrote: adding media plugin, 'Media.Coupler', behavior to users plugin model prevent creating new user. I want to save the profile image path in users table. Any suggestions? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin and user plugin
I didn't change register action at all. I just added the Media behaviors to user model $actsAs. Its working perfectly in other controllers. Anyway I found a solution: I needed the media plugin in order to upload the user profile image. I removed the 'Media.Coupler' from the user model $actsAs and add this code at user controller upload_image action: public function upload_image() { $this-User-Behaviors-attach('Media.Coupler'); ... ... $this-User-Behaviors-detach('Media.Coupler'); $this-redirect($this-referer()); } But it means that I can't add image_file field to registration form. After the user registered and verified his account he should enter his profile page and add an image. I should try using the media plugin on a clean solution to decide where is the problem On Fri, Sep 16, 2011 at 12:34 PM, WebbedIT p...@webbedit.co.uk wrote: More information required ... - have you echoed $this-data on submit to see what data there is - how are you calling save in the controller? - have you looked at the sql dump to see what Cake is trying? HTH, Paul @phpMagpie On Sep 15, 11:11 am, ZAky procsh...@gmail.com wrote: adding media plugin, 'Media.Coupler', behavior to users plugin model prevent creating new user. I want to save the profile image path in users table. Any suggestions? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin and user plugin
More information required ... - have you echoed $this-data on submit to see what data there is - how are you calling save in the controller? - have you looked at the sql dump to see what Cake is trying? HTH, Paul @phpMagpie On Sep 15, 11:11 am, ZAky procsh...@gmail.com wrote: adding media plugin, 'Media.Coupler', behavior to users plugin model prevent creating new user. I want to save the profile image path in users table. Any suggestions? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin transferTo
You can maybe do it manualy : don't use Media.Transfer But i don't know if you can use Media transfert methods in your controller after saving the post. something like that : function add() { $this-Post-create(); if ($this-Post-save($this-data)) { […] $dirname = 'files/'.$this-Session-read('Auth.User.id').'/'.$this- Post-id; $this-Post-saveField('dirname', $dirname); // transfert } else { // Error } } The simplest would be to let Media plugin transfert in Media folder, the path would be store in DB with dirname and basename. On 14 sep, 12:43, Zaky Katalan-Ezra procsh...@gmail.com wrote: Thank you Media plugin some how bind to the save function. So How do I tell the media plugin not to run after save and run only when I have the post_id? On Wed, Sep 14, 2011 at 11:47 AM, BenJsno bench...@yahoo.fr wrote: You have to save your post before upload the file. in your Post_controller : function add() { [...] if (!empty($this-data)) { $this-Post-create(); if ($this-Post-save($this-data)) { [...] $new_id = $this-Post-id // you can maybe put this data temporarily in the session $this-Session-write('Post.last_id', $this-Post-id); } else { [...] } } [...] } Hope this helps you On 13 sep, 13:24, ZAky procsh...@gmail.com wrote: I save my posts files under /files/[user_id]/[post_id]/[image]. This mean I need to know the just seved post id in Post-transfer_to. How do I achieve that? Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Regards, Zaky Katalan-Ezra QA Administratorwww.IGeneriX.com Sites.IGeneriX.com 054-7762312 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media plugin and user plugin
adding media plugin, 'Media.Coupler', behavior to users plugin model prevent creating new user. I want to save the profile image path in users table. Any suggestions? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin transferTo
You have to save your post before upload the file. in your Post_controller : function add() { [...] if (!empty($this-data)) { $this-Post-create(); if ($this-Post-save($this-data)) { [...] $new_id = $this-Post-id // you can maybe put this data temporarily in the session $this-Session-write('Post.last_id', $this-Post-id); } else { [...] } } [...] } Hope this helps you On 13 sep, 13:24, ZAky procsh...@gmail.com wrote: I save my posts files under /files/[user_id]/[post_id]/[image]. This mean I need to know the just seved post id in Post-transfer_to. How do I achieve that? Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin transferTo
Thank you Media plugin some how bind to the save function. So How do I tell the media plugin not to run after save and run only when I have the post_id? On Wed, Sep 14, 2011 at 11:47 AM, BenJsno bench...@yahoo.fr wrote: You have to save your post before upload the file. in your Post_controller : function add() { [...] if (!empty($this-data)) { $this-Post-create(); if ($this-Post-save($this-data)) { [...] $new_id = $this-Post-id // you can maybe put this data temporarily in the session $this-Session-write('Post.last_id', $this-Post-id); } else { [...] } } [...] } Hope this helps you On 13 sep, 13:24, ZAky procsh...@gmail.com wrote: I save my posts files under /files/[user_id]/[post_id]/[image]. This mean I need to know the just seved post id in Post-transfer_to. How do I achieve that? Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Regards, Zaky Katalan-Ezra QA Administrator www.IGeneriX.com Sites.IGeneriX.com 054-7762312 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media plugin transferTo
I save my posts files under /files/[user_id]/[post_id]/[image]. This mean I need to know the just seved post id in Post-transfer_to. How do I achieve that? Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media Plugin Tutorial
Here's a simple tutorial to help get you started: http://sopix.wordpress.com/2010/12/28/media-plugin-of-cakephp-tutorial/ Ben -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin Tutorial
Anyone know where I can find a tutorial for David Persson's Media Plugin Tutorial? Documentations seems scarce and questions here are all relating to issues with the plugin, there doesn't seem to be a starting point. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin and saveAll
Hi Michal, I run into the same problem and finally found that I had to remove the 'Media.Coupler' from the $actAs array. Hope that works for you too! Theclansman On Jul 8, 10:42 pm, michalmalinowski mmichal.malinow...@gmail.com wrote: Hey, I have the same problem as Bradhttp://groups.google.com/group/cake-php/browse_thread/thread/aa331e6a... I am able to edit record with attachment, change attachment, change user data etc. But I can not create new record in the 'user' model. I tried different options: -disabled validator -check what will be saved in beforeSave() -check database queries [11] = Array ( [query] = START TRANSACTION [error] = [affected] = 0 [numRows] = [took] = 0 ) [12] = Array ( [query] = COMMIT [error] = [affected] = 0 [numRows] = [took] = 0 ) that is all.. With every option that I tried my $this-data['User'] will be empty in the beforeSave(), but it's not in controller. When I'm trying if($this-User-saveAll($this-data, 'validate' = 'first')) script always returns true, but nothing will be saved. Can anyone please advise with that? At least in which direction we can do research etc. Michal -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin and saveAll
Hey, I have the same problem as Brad http://groups.google.com/group/cake-php/browse_thread/thread/aa331e6a9938f242/779445eead7e9b12?lnk=gstq=saveall+media#779445eead7e9b12 I am able to edit record with attachment, change attachment, change user data etc. But I can not create new record in the 'user' model. I tried different options: -disabled validator -check what will be saved in beforeSave() -check database queries [11] = Array ( [query] = START TRANSACTION [error] = [affected] = 0 [numRows] = [took] = 0 ) [12] = Array ( [query] = COMMIT [error] = [affected] = 0 [numRows] = [took] = 0 ) that is all.. With every option that I tried my $this-data['User'] will be empty in the beforeSave(), but it's not in controller. When I'm trying if($this- User-saveAll($this-data, 'validate' = 'first')) script always returns true, but nothing will be saved. Can anyone please advise with that? At least in which direction we can do research etc. Michal -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
media plugin filter configuration multiple issue
hi, i am using media plugin 1.3 alpha in cakephp 1.3. I need to upload files from 2 different models with different sizes. But there is only one Filter configuration for the plugin. Is there a way around it so i can use the plugin to generate different file sizes for different models? thanks in advance! david -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: media plugin filter configuration multiple issue
well.. i guess i solved the problem. for anyone else who is facing a similar one, the solution is to copy the configuration in the model file itself On May 29, 11:17 pm, crazyDavid iamcrazyda...@gmail.com wrote: hi, i am using media plugin 1.3 alpha in cakephp 1.3. I need to upload files from 2 different models with different sizes. But there is only one Filter configuration for the plugin. Is there a way around it so i can use the plugin to generate different file sizes for different models? thanks in advance! david -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
how to embed image in david persson's media plugin
I'm using Media Plugin 1.3 beta with CakPHP 1.3. I've successfully uploaded the images with the plugin. But how do i use the Media helper to embed the image file uploaded in the view??? plz help! Thanks! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson's Media Plugin
Hello Folks, I'm working on my first project with cakephp and I ran into an issue when trying to implement file uploads: 1) I'm trying to use the media plugin for my application. I'm having problems to apply the polymorphic behavior to the model. Here are my models and the controller: models/attachment.php: http://pastie.org/private/qjofpjluwaxsgr4t99jw models/artist.php: http://pastie.org/private/oqhz5isx4npxdo1b0olvew controllers/artists_contoller.php: http://pastie.org/private/x1u10dbgc9awwpxhulqcw When I upload a new file, its saved correctly into the attachments table, but without the foreign_key or the model fields being set. 2) I tried as well to manually add this fields by extending $this- data in my controller, but I end up with a broken string in my database. Here is the controller with the manually specified model and foreign_key: http://pastie.org/private/wrgxo9sdspar3sdxgrpyyq and the field if its read by the Artist view: http://666kb.com/i/bt7evphoib2ca2m6y.gif Regards, Stefan. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
As to be expected, work's like a charm! Many thanks David for the fix and the plugin. d//t On Apr 27, 11:55 pm, David Persson nper...@gmx.de wrote: Hey, I think this commit will fix the issues with the mapping between MIME-type and name.https://github.com/davidpersson/mm/commit/707ab2cd6b9452403cd56fd4aac... The fix has also been already propagated to the media plugin. In case it doesn't work for you please open an issue here:https://github.com/davidpersson/media/issues or therehttps://github.com/davidpersson/mm/issues - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
Likewise Ryan, it hasn't really held me up making this app, just one of those niggles. Cricket - I have obviously googled the issue, and there are different MIME types for the later Office Doc types, and I am sure there is a way to fix the plugin to handle this issue. Thereason for my sparse explanation is that I know the author checks the group fairly regularly and figured if there was a 'quick fix' he'd know about it. The Media Plugin is an excellent example of a pluign and quite complicated, I would much rather implement an 'official' fix than dive in and start hacking it around myself. That said, if there isn't and the 'niggle' becomes to annoying then obviously I will. On Apr 27, 2:52 am, Ryan Snowden sicapi...@gmail.com wrote: Same here - My docx go through to 'gen', but the MIME type is recognised by the plugin correctly. I didn't see it as a problem though as I can still get the file :) On 27 April 2011 01:58, cricket zijn.digi...@gmail.com wrote: What have you done to debug the problem? What's different about these files? MIME type maybe? What does google say about these files and their MIME? How might the solutions you find online be used with Cake? On Tue, Apr 26, 2011 at 9:23 AM, designv...@gmail.com designv...@gmail.com wrote: Anyone? On Mar 22, 12:13 pm, designv...@gmail.com designv...@gmail.com wrote: Hi there, Has anyone got any idea how to get the Media Plugin to recognise Office 2007 files correctly? I can upload old .doc files fine and they get put in the 'doc' folder, and don't fail the mime validation rule, but it really doesn't like .docxfiles.. Any suggestions? d//t -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Aw: Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
Hey, I think this commit will fix the issues with the mapping between MIME-type and name. https://github.com/davidpersson/mm/commit/707ab2cd6b9452403cd56fd4aaccc8ec345919df The fix has also been already propagated to the media plugin. In case it doesn't work for you please open an issue here: https://github.com/davidpersson/media/issues or there https://github.com/davidpersson/mm/issues - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin
More than one of my apps are doing this so I am very confused. I am using Show hasMany Attachment. I try and create a new record and it uploads and resizes the image and saves the record to my Attachment model without a foreign_key but with the correct model (Show). However, it does NOT save the main record in my Show model. The flash says the record has been saved but it hasn't. If I EDIT a preexisting record, the image is uploaded, resized and saved to the Attachment db with the foreign_key. Any help would be greatly appreciated. I would really like to be able to use this plugin as it looks amazing but can't figure this one hurdle out. Thank you. show.php var $actsAs = array( 'Sluggable' = array('overwrite' = 'true'), 'Tags.Taggable', 'Media.Transfer', 'Media.Generator', 'Media.Coupler' ); var $hasMany = array( 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'dependent' = true, 'conditions' = array('Attachment.model' = 'Show') ), ); shows_controller.php function admin_add() { if (!empty($this-data)) { $this-Show-create(); if ($this-Show-saveAll($this-data, array('validate' = 'first'))) { $this-Session-setFlash(__('The show has been saved', true)); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash(__('The show could not be saved. Please, try again.', true)); } } $users = $this-Show-User-find('list', array( 'conditions' = array('User.group_id' = array('1', '3')), 'fields' = array('User.username'), 'order' = array('User.username' = 'asc') ) ); $this-set(compact('users')); } function admin_edit($id = null) { if (!$id empty($this-data)) { $this-Session-setFlash(__('Invalid show', true)); $this-redirect(array('action' = 'index')); } if (!empty($this-data)) { if ($this-Show-saveAll($this-data, array('validate' = 'first'))) { $this-Session-setFlash(__('The show has been saved', true)); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash(__('The show could not be saved. Please, try again.', true)); } } if (empty($this-data)) { $this-data = $this-Show-read(null, $id); } $users = $this-Show-User-find('list', array( 'conditions' = array('User.group_id' = array('1', '3')), 'fields' = array('User.username'), 'order' = array('User.username' = 'asc') ) ); $this-set(compact('users')); } admin_add.ctp ?php echo $this-Form-create('Show', array('enctype' = 'multipart/ form-data'));? fieldset legend?php __('Admin Add Show'); ?/legend ?php echo $this-Form-input('user_id', array('empty' = true)); echo $this-Form-input('title'); echo $this-Form-input('description'); echo $this-element('attachments', array('plugin' = 'media')); echo $this-Form-input('tags', array('type' = 'text')); ? /fieldset ?php echo $this-Form-end(__('Submit', true));? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
Anyone? On Mar 22, 12:13 pm, designv...@gmail.com designv...@gmail.com wrote: Hi there, Has anyone got any idea how to get the Media Plugin to recognise Office 2007 files correctly? I can upload old .doc files fine and they get put in the 'doc' folder, and don't fail the mime validation rule, but it really doesn't like .docxfiles.. Any suggestions? d//t -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
What have you done to debug the problem? What's different about these files? MIME type maybe? What does google say about these files and their MIME? How might the solutions you find online be used with Cake? On Tue, Apr 26, 2011 at 9:23 AM, designv...@gmail.com designv...@gmail.com wrote: Anyone? On Mar 22, 12:13 pm, designv...@gmail.com designv...@gmail.com wrote: Hi there, Has anyone got any idea how to get the Media Plugin to recognise Office 2007 files correctly? I can upload old .doc files fine and they get put in the 'doc' folder, and don't fail the mime validation rule, but it really doesn't like .docxfiles.. Any suggestions? d//t -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson - Media Plugin - Handing .docx and .xlsx uploads
Same here - My docx go through to 'gen', but the MIME type is recognised by the plugin correctly. I didn't see it as a problem though as I can still get the file :) On 27 April 2011 01:58, cricket zijn.digi...@gmail.com wrote: What have you done to debug the problem? What's different about these files? MIME type maybe? What does google say about these files and their MIME? How might the solutions you find online be used with Cake? On Tue, Apr 26, 2011 at 9:23 AM, designv...@gmail.com designv...@gmail.com wrote: Anyone? On Mar 22, 12:13 pm, designv...@gmail.com designv...@gmail.com wrote: Hi there, Has anyone got any idea how to get the Media Plugin to recognise Office 2007 files correctly? I can upload old .doc files fine and they get put in the 'doc' folder, and don't fail the mime validation rule, but it really doesn't like .docxfiles.. Any suggestions? d//t -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media Plugin — Trouble with filtered files
ups... Ups, my bad. Should have been Configure::write('Media.filter.image.s', array( On Apr 25, 1:47 am, skimmas skim...@gmail.com wrote: in my config/core.php I added /* CAKE MEDIA PLUGIN */ require APP . 'plugins/media/config/core.php'; Configure::write('Media.filter.document.s', array( 'convert' = 'image/jpeg', 'compress' = 1.5, 'fit' = array(100, 100) )); Yet the media plugin is still generating a png image. Do you guys have any ideia what's going on. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin — Trouble with filtered files
in my config/core.php I added /* CAKE MEDIA PLUGIN */ require APP . 'plugins/media/config/core.php'; Configure::write('Media.filter.document.s', array( 'convert' = 'image/jpeg', 'compress' = 1.5, 'fit' = array(100, 100) )); Yet the media plugin is still generating a png image. Do you guys have any ideia what's going on. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: tiny question on Media plugin and CouplerBehavior
I would like to use Coupler behavior for the beforeDelete method and the afterFind method, but finaly I don't use Coupler Behaviors anymore, because i don't give a file in my form. Maybe that's why the Model::exists() returns false, i don't know... I modified the Mediafiles Model's beforeDelete method to delete all files (Transfert and filters) app/models/mediafile.php : pre class Mediafile extends AppModel{ var $name = Mediafile; //media plugin behaviors var $actsAs = array( 'Media.Generator' = array( 'baseDirectory' = MEDIA_TRANSFER, 'filterDirectory' = MEDIA_FILTER, 'createDirectory' = true, 'overwrite' = true ), 'Media.Polymorphic' ); //file validation which only allowed jpeg and png to be uploaded var $validate = array( 'file' = array( 'mimeType' = array( 'rule' = array('checkMimeType', false, array( 'image/jpeg', 'image/png')) ) ) ); var $belongsTo = array( 'User' = array( 'className' = 'User', 'foreignKey' = 'foreign_key', 'conditions' = '', 'fields' = '', 'order' = '' ), 'Homeslide' = array( 'className' = 'Homeslide', 'foreignKey' = 'foreign_key', 'conditions' = '', 'fields' = '', 'order' = '' ) ); // delete transfert and filters files public function beforeDelete($cascade = true) { if (!$cascade) { return true; } $result = $this-find('first', array( 'conditions' = array($this-primaryKey = $this-id), 'fields' = array('dirname', 'basename'), 'recursive' = -1 )); if (empty($result)) { return false; } $fileT = MEDIA_TRANSFER ; $fileT .= $result[$this-alias]['dirname']; $fileT .= DS . $result[$this-alias]['basename']; $FileT = new File($fileT); if (!$FileT-delete()) { return false; } $pattern = MEDIA_FILTER . */; $pattern .= $result[$this-alias]['dirname'] . '/'; $pattern .= pathinfo($result[$this-alias]['basename'], PATHINFO_FILENAME); $files = glob({$pattern}.*); $name = Mime_Type::guessName($result[$this-alias] ['basename']); $versions = array_keys(Configure::read('Media.filter.' . $name)); if (count($files) count($versions)) { $message = 'MediaFile::beforeDelete - '; $message .= Pattern `{$pattern}` matched more than number of versions. ; $message .= Failing deletion of versions and record for `Media@{$this-id}`.; CakeLog::write('warning', $message); return false; } foreach ($files as $file) { $File = new File($file); if (!$File-delete()) { return false; } } return true; } } /pre Thanks BenJsno On 5 avr, 10:59, David Persson nper...@gmx.de wrote: Hi, The coupler behavior's beforeSave method looks like it is doing too much having too many sideeffects. I'll take a look at it and see if I can reduce those to a mininum. Will get back and post the results than. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin + MM + image generated with an other extension than image transfered
Hi, I have an other problem with media plugin. when I upload a jpeg file with .jpeg extension, in my DB i have, for exemple, picture.jpeg in the basename field. But the Generator Behavior make filter versions with .jpg extension. So i don't have a correct path for filter versions. I have no conversion in the bootstrap. How can i configure the file extensions to have the same extension than the uploaded file? is it GD who choose the extension? I would like upload .jpg and .jpeg file. in my config/bootstrap.php : require APP . 'plugins' . DS . 'media' . DS . 'config' . DS . 'core.php'; $org = array('fitInside' = array(900, 900)); $small = array('fitCrop' = array(75, 75)); $medium = array('fitCrop' = array(300, 300)); $large = array('fitCrop' = array(900, 300)); Configure::write('Media.filter', array( 'audio' = array(), 'document' = array(), 'generic' = array(), 'image' = compact('small', 'medium', 'large', 'org'), 'video' = array() )); Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: tiny question on Media plugin and CouplerBehavior
In fact, i don't need to use make method in my add fonction. I just saw it enough to have dirname and basename for Generator Behavior makes the versions. Anyway, i think the real problem is why $Model-exists() return false in BeforeSave method in Coupler Behavior Is it normal? Am I missing something my new app/model/mediafile.php : class Mediafile extends AppModel{ var $name = Mediafile; //media plugin behaviors var $actsAs = array( 'Media.Coupler' = array( 'baseDirectory' = MEDIA_TRANSFER, 'filterDirectory' = MEDIA_FILTER ), 'Media.Generator' = array( 'baseDirectory' = MEDIA_TRANSFER, 'filterDirectory' = MEDIA_FILTER, 'createDirectory' = true, 'overwrite' = true ), 'Media.Polymorphic' ); //file validation which only allowed jpeg and png to be uploaded var $validate = array( 'file' = array( 'mimeType' = array( 'rule' = array('checkMimeType', false, array( 'image/jpeg', 'image/png')) ) ) ); var $belongsTo = array( 'User' = array( 'className' = 'User', 'foreignKey' = 'foreign_key', 'conditions' = '', 'fields' = '', 'order' = '' ), 'Homeslide' = array( 'className' = 'Homeslide', 'foreignKey' = 'foreign_key', 'conditions' = '', 'fields' = '', 'order' = '' ) ); // delete filters files public function beforeDelete($cascade = true) { if (!$cascade) { return true; } $result = $this-find('first', array( 'conditions' = array($this-primaryKey = $this-id), 'fields' = array('dirname', 'basename'), 'recursive' = -1 )); if (empty($result)) { return false; } $pattern = MEDIA_FILTER . */; $pattern .= $result[$this-alias]['dirname'] . '/'; $pattern .= pathinfo($result[$this-alias]['basename'], PATHINFO_FILENAME); $files = glob({$pattern}.*); $name = Mime_Type::guessName($result[$this-alias] ['basename']); $versions = array_keys(Configure::read('Media.filter.' . $name)); if (count($files) count($versions)) { $message = 'MediaFile::beforeDelete - '; $message .= Pattern `{$pattern}` matched more than number of versions. ; $message .= Failing deletion of versions and record for `Media@{$this-id}`.; CakeLog::write('warning', $message); return false; } foreach ($files as $file) { $File = new File($file); if (!$File-delete()) { return false; } } return true; } } Thanks for your help On 5 avr, 10:59, David Persson nper...@gmx.de wrote: Hi, The coupler behavior's beforeSave method looks like it is doing too much having too many sideeffects. I'll take a look at it and see if I can reduce those to a mininum. Will get back and post the results than. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: tiny question on Media plugin and CouplerBehavior
Hi, The coupler behavior's beforeSave method looks like it is doing too much having too many sideeffects. I'll take a look at it and see if I can reduce those to a mininum. Will get back and post the results than. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
tiny question on Media plugin and CouplerBehavior
Hello, I would like to use the Media plugin in my application and my question is in media/models/behaviors/coupler.php, what is the goal of the line 104 ? is it usefull for something ? line 104 : unset($Model-data[$Model-alias]); In my exemple, I have a table Mediafiles CREATE TABLE `mediafiles` ( `id` int(11) unsigned NOT NULL auto_increment, `dirname` varchar(100) collate utf8_unicode_ci NOT NULL, `basename` varchar(60) collate utf8_unicode_ci NOT NULL, `model` varchar(20) collate utf8_unicode_ci NOT NULL, `foreign_key` int(11) unsigned NOT NULL, `size` int(11) NOT NULL, `width` int(10) unsigned NOT NULL, `height` int(10) unsigned NOT NULL, `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=11 ; I use uploadify for uploading my file with progressbar and Media plugin to add data in DB and make the thumb with Generator behavior. models/mediafile.php : class Mediafile extends AppModel{ var $name = Mediafile; //media plugin behaviors var $actsAs = array( 'Media.Coupler', 'Media.Generator' ); //file validation which only allowed jpeg and png to be uploaded var $validate = array( 'fileData' = array( 'mimeType' = array( 'rule' = array('checkMimeType', false, array( 'image/jpeg', 'image/png')) ) ) ); var $belongsTo = array( 'User' = array( 'className' = 'User', 'foreignKey' = 'mediafile_id', 'conditions' = '', 'fields' = '', 'order' = '' ), 'Homeslide' = array( 'className' = 'Homeslide', 'foreignKey' = 'mediafile_id', 'conditions' = '', 'fields' = '', 'order' = '' ) ); } controllers/mediafiles_controller.php : class MediafilesController extends AppController { var $name = 'Mediafiles'; var $components = array('RequestHandler', 'Cuploadify.cuploadify'); function upload_img() { $this-cuploadify-upload(); } function add() { $this-layout = admin; if (!empty($this-data)) { $this-data['Mediafile']['dirname'] = 'img'; // Thumb creation with Media Plugin $this-Mediafile-make($this-data['Mediafile']['dirname'] . DS . $this-data['Mediafile']['basename']); // save in DB if ($this-Mediafile-save($this-data)) { $result = 'div id=outputsuccess/div'; $result .= 'div id=messagemediafile_id = '.$this-Mediafile- id.'/div'; }else{ $result = div id='output'failed/div; $result .= 'div id=message'. $this-Mediafile- validationErrors['file'] .'/div'; } $this-set(compact('result')); } } } I use a component for uploadify controllers/components/cuploadify.php So I upload the file in ajax (upload_img()) and then I submit the form with data but without file input (add()). In add function The generator part works fine. But when I save the data, the Coupler BeforeSave function don't find $Model [in media/models/behaviors/coupler.php line 102] ( I don't understand why) and then don't find file input (because there is no file input, only hidden input) then the $Model-data[$Model-alias] is unset [in media/models/ behaviors/coupler.php line 104] and return true but don't save data in DB. if I comment the line 104, the data are saved. I would really appreciate a clarification on this point. Thank you -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson - Media Plugin - Handing .docx and .xlsx uploads
Hi there, Has anyone got any idea how to get the Media Plugin to recognise Office 2007 files correctly? I can upload old .doc files fine and they get put in the 'doc' folder, and don't fail the mime validation rule, but it really doesn't like .docx files.. Any suggestions? d//t -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin - usage questions
I'm trying to do something similar (as described in this thread http://groups.google.com/group/cake-php/browse_thread/thread/9fdfef27f01e5ef7). I'm able to POST my image and save it to a folder but I don't know how to invoke the media plugin to make multiple sizes of that file. How were you able to get the media plugin to handle your files, I'm assuming you have nothing in your view and basically submitting to your controller? I also need to return the file name of the processed image file (looks like David explained that). Thanks -Foroct -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin - usage questions
Hi Foroct, I've answered you in the other thread. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Edit with Media Plugin David Persson
Hi, When I try to edit a media file ex. I need to replace the image The main image was replaced but the filter (an 'm' and 'l') image wasn't replaced. And the replaced image wasn't deleted. Where I'm wrong? Thanks in advance! Alberto -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Edit with Media Plugin David Persson
Hi Alberto, Given you're using the coupler behavior and you replace a file but leave its corresponding record in tact, the file which gets replaced won't be deleted. This is by design. It is expected that when replacing a file you would rather go and delete the complete old record. Than create a new record with a new file associated with it. In the scenario described your old file would get deleted as the beforeDelete hook of the coupler behavior gets triggered and takes care of that. Now to the versions of the file. I've removed support for automatically deleting versions of a file in the current version of the media plugin. It turned out that how, which and when to delete the generated versions is highly application specific. However you can still take care of that yourself for example in the before or afterDelete of your file model. See https://gist.github.com/859371 for an example. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: CakePHP Media Plugin
Hi Alberto, If I were you I'd just implement my own validation rule for that. See [1] for how that is accomplished in the plugin. Be sure to also check the chapter about that topic at book.cakephp.org. [1] https://github.com/davidpersson/media/blob/1.3/models/behaviors/transfer.php#L741 - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: more fields for David Persson's media plugin form?
Hello Tan Cheng, Just add a new input to your form: echo $form-input('file', array('type' = 'file', 'label' = false, 'class' = 'imageUpload')); echo $form-input('title'); Be sure $this-data looks somewhat like this in your controller action: array( 'Gallery' = array( 'file' = '...', 'title' = 'My Title' ) ); Than just save the record as you normally do. Make sure there's a 'title' column in the table schema. That's basically it. In case you're using a separate table i.e. 'images' to store the file data instead of storing it in the 'galleries' table follow these instructions: * Gallery and Image models must be associated with each other hasMany/hasOne/... * Your form must produce a data array which reflects this structure (see [1]). * Use saveAll in your controller action. [1] http://book.cakephp.org/view/1032/Saving-Related-Model-Data-hasOne-hasMany-belongsTo - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin - usage questions
Hi Will, I think what you're searching for can be found at [1]. Use the method like this: $this-Post-save($this-data); $file = $this-Post-transferred(); [1] https://github.com/davidpersson/media/blob/1.3/models/behaviors/transfer.php#L461 - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
CakePHP Media Plugin
Hi, I want to add a validate rule for my model in the CakePHP Media Plugin. I want that for this rule 'pixels' = array('rule' = array('checkPixels', '1366x768')), the pixels have to be exactly se same of 1366x768 and not = of 1366x768 Is it possible to use this rule? Thank in advance! Alberto -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
more fields for David Persson's media plugin form?
Hi everyone, I am now using David Persson's media plugin to handle the ajax upload now. But the upload form only shows the file type input, like ?php echo $form-create('Gallery', array('type' = 'file')); echo $form-input('file', array('type' = 'file', 'label' = false, 'class' = 'imageUpload')); echo $form-end(); ? What if I want to add more fields, like the title of the photo or some description to add to my image table in db? I have added $form- input('title'), but it doesn't show up at all. Anyone had experience using this plugin? How to customise this? Thank you very much!! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media plugin - usage questions
ad 1) You have to use the path constant MEDIA to identify where the files are stored and then combine it with the information for the requested file - directory and filename - adding it all together to get the filename with path information. Read the configuration for the Media plugin here: https://github.com/davidpersson/media/blob/1.3/config/core.php ad 2) PUT, is that not about REST then? Enjoy, John On Feb 25, 8:23 pm, will.brooke will.bro...@gmail.com wrote: Hi All, I am trying to use the media plugin (https://github.com/davidpersson/ media) for a funky API project. I have 2 issues right now. I can POST susbmit a file and it gets saved. huzzah. (if you care, they are CSV files) what I need is: 1.) after save completes in the controller, I need the path and filename (the actual stored filename on disk) of the just submitted file. i need this to pass to a function in the model that calls a postgres function that then handles the CSV file. i assumed i could get this via something like: $this-Attachment- basepath but no such luck. 2.) I would like to use PUT to submit the file. other than re-routing the edit behaviour, i can't wrap my head around how to handle this. any help greatly appreciated -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media plugin - usage questions
Hi All, I am trying to use the media plugin (https://github.com/davidpersson/ media) for a funky API project. I have 2 issues right now. I can POST susbmit a file and it gets saved. huzzah. (if you care, they are CSV files) what I need is: 1.) after save completes in the controller, I need the path and filename (the actual stored filename on disk) of the just submitted file. i need this to pass to a function in the model that calls a postgres function that then handles the CSV file. i assumed i could get this via something like: $this-Attachment- basepath but no such luck. 2.) I would like to use PUT to submit the file. other than re-routing the edit behaviour, i can't wrap my head around how to handle this. any help greatly appreciated -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Media Plugin - Newbie Questions
I'm trying to set up the Media plugin, but am having problems. I have a PressRelease model, and while adding an entry I would like to choose and upload a PDF file to associate with it. But when adding an entry, the press_releases table receives an entry, and the attachment table does not. *If I use the baked Attachment view to add an entry the attachments table DOES receive the row. I have followed the documentation, updated the bootstrap file, etc. Below is the relevant code from the Press Release model, controller and view. If you have any idea what I correct, please advise. Thanks! A few simple questions also: 1. Do I need to add this ... var $helpers = array('Media.Media'); ... to my PressRelease model? 2. Do I need to add belongsTo data to the Attachment model? -- Code Provided Below -- The Press Release model has this: var $hasOne = array( 'Attachment' = array( 'className' = 'Media.Attachment', 'foreignKey' = 'foreign_key', 'conditions' = array('Attachment.model' = 'PressRelease'), 'dependent' = true, )); The Press Release controller has this: function admin_add() { $this-layout = 'admin'; if (!empty($this-data)) { $this-PressRelease-create(); if ($this-PressRelease-saveAll($this-data, array('validate' = 'first'))) { $this-Session-setFlash('The press release has been saved.', 'flash_success'); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash('The press release could not be saved. Please, try again.', 'flash_error'); } } $projects = $this-PressRelease-Project-find('list'); $this-set(compact('projects')); } The form in the view looks like this: div class=pressReleases form ?php echo $this-Form-create('PressRelease', array('enctype' = 'multipart/form-data'));? fieldset legend?php __('Add Press Release'); ?/legend ?php $current_year = date('Y'); $max_year = $current_year + 2; $unix_timestamp = strtotime('now'); echo $this-Form-input('date', array('type'='date', 'minYear'=2005, 'maxYear'=$max_year, 'selected'=$unix_timestamp)); echo $this-Form-input('title'); echo $this-Form-input('file', array('label' = 'File', 'type' = 'file')); echo $this-Form-input('Project',array('label'='Related Project(s)', 'multiple' = 'checkbox')); ? /fieldset ?php echo $this-Form-end(__('Add Press Release', true));? /div -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Media Plugin - Newbie Questions
I don't know anything about the Media plugin, however your problem may be with how you have created your inputs in the view. Have you looked at the structure of $this-data once the form has been submitted to your action (admin_add)? In order for saveAll() to work. It should look something like: array( [PressRelease]=array( [date]=// some date . // other fields . [Attachment]=array( [file]=// some file name In your view you have: echo $this-Form-input('file', array('label' = 'File', 'type' ='file')); It may be as simple as changing this to: echo $this-Form-input('Attachment.file', array('label' = 'File', 'type' ='file')); BTW, saveAll() will save related model data ONLY if the array passed is properly structured AND it is only one level deep. HTH, Ken -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin - regenerate image versions
Hi, Have a look at the Media shell. It comes with the plugin and features one specific task which may be helpful in your situation. $ cake media make Will prompt you for source and destination path and will then recreate versions of each file. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: David Persson Media Plugin - regenerate image versions
Ahhh! Brilliant! Now I just have to work out how to run that on the server - I can run the shell stuff locally, but no idea how to do it on my Media Temple server... but awesome news, thanks! d. On Jan 28, 9:47 am, David Persson davidpers...@gmx.de wrote: Hi, Have a look at the Media shell. It comes with the plugin and features one specific task which may be helpful in your situation. $ cake media make Will prompt you for source and destination path and will then recreate versions of each file. - David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
David Persson Media Plugin - regenerate image versions
Hi there, I have very successfully got the Media/Attachments plugin working on my new site, and I'm really impressed, but have run into a slight problem... The site is a rebuild of an existing site and has around 2000 images attached to news stories (the app folder weighs in at around 900mb!), now I have copied the images into the 'filter' 'img' directory and manually resized them as per the config settings for the plugin and do some mysql kung fu to import them into the database table. However, this is fine locally, but it's going to be a RIGHT nightmare to upload and none of the images have checksum etc. What I would like to be able to is some kind of batch add/resize for all the images if they are in the 'transfer' directory once it's on the server, maybe a is the requested image in the transfer directory and not the filter directory? If now, run the resizing process... So the resizing is done when the news story is first viewed... Does this seem doable? TIA, d. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php