Tuesday, June 28, 2011

Re: Multiple images in one row - David Perssons Media Plug-in

Slightly odd behaviour. I added hidden fields to populate:
- Profile.Logo.foreign_key to the id of the associated record in Profile: this is fine (in my test it's 1)
- Profile.Logo.model to 'Profile': this is losing it's first character and being replaced by '1'
- a text value of 'logo' for Profile.Logo.group: this is losing it's first character and being replaced by '1'

When I test with another row where Profile.id = 2 Profile.Logo.model becomes '2rofile' and Profile.Logo.group becomes '2ogo'.
Any clues?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 28 Jun 2011, at 17:10, Jeremy Burns | Class Outfit wrote:

Bingo. Perfect, thanks. I worked out that the 'm' at the beginning refers to the 'medium' size, which explained why it was rendering a zoomed and constrained image. I changed that to 'l' and the proper sized image appeared.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 28 Jun 2011, at 16:40, jeremyharris wrote:

I have experience with the Media plugin. First, congrats on getting it up and running w/o docs ;) 

What you want is Profile hasMany Image. That way a user can have multiple images. If you want "types" of images per user, you can use the 'group' field included in the SQL he provides. Or, you can always add your own field to the attachments table, it's still just a table.

For rendering the image, you can use the embed method on the Media helper:

$path = 'm'.DS.$image['Image']['dirname'].DS.$image['Image']['basename'];
echo $this->Media->embed($path, array('restrict' => 'image'));

As I recall if you're using Coupler it should add a 'path' key so you don't need to concat the basename and dirname. In the 'next' branch, there's a sample virtual field which accomplishes the same thing.

hth,
jeremy

--
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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: