• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeExtinguisher 2.0 Release Candidate 14.2

[eluser]Majd Taby[/eluser]
just remove the second Image and it should generate the thumbnail automatically. check the uploads/ folder

[eluser]unsub[/eluser]
Hi JamesL

although I'm not a CE xpert by any means, I think the way I would suggest you do this is to just add your image manipulation code to the image plugin ( ~/codex/application/plugins/image.php )

then you won't have to do anything in the form controller at all. the thumbnail stuff is taken care of in the image plugin, so just off hand it seems to me to be the logical place to make other changes to the image.

hope that helps point you in the right direction.

Best regards,
-g

[eluser]JamesL[/eluser]
Thank you for the quick response.

This generates one thumbnail automatically, but I need to resize the original image and then create a thumbnail. So I want to have a two step process.

1. resize the image to a max height / width of 540px
2. then create a thumbnail of 40x40

Does this make sense?

Thanks.

[eluser]JamesL[/eluser]
g,

That makes sense to me, if there isn't a built-in method to setup a two step process I will give that a shot.

Thanks, JamesL

[eluser]JamesL[/eluser]
After a short break I took g's advice and modified the image.php file so that the script now does exactly what I want it to. I hard coded the smaller thumbnail parameters into the script, although a more elegant solution would be to add to the parameters the script accepts to allow for this kind of image handling. I'm not sure how common this kind of request is, but I would be happy to post my code if anyone needs it.

g and JTabby, thanks again for your quick replys.

Best, JamesL

[eluser]unsub[/eluser]
[quote author="JamesL" date="1220066368"]After a short break I took g's advice and modified the image.php file so that the script now does exactly what I want it to. I hard coded the smaller thumbnail parameters into the script, although a more elegant solution would be to add to the parameters the script accepts to allow for this kind of image handling. I'm not sure how common this kind of request is, but I would be happy to post my code if anyone needs it.

g and JTabby, thanks again for your quick replys.

Best, JamesL[/quote]

Hi, JamesL,

glad it works for you.

One thing I wonder though, is why not send the thumbnail dimensions in the form setup? In the controller, in the $config array where you are defining your fields, it's like this:
Code:
'image'=>array(
    'class'=>'Image',
    'label'=>'Upload Picture',
    'params'=>array(
        'make_thumbnail'=>'true',
        'width'=>'40', 'height'=>'40',
        'url_path'=>'path/to/image_folder/',
        'upload_path'=>'./path/to/image_folder/',
        'display_name'=>'My Pictures'
    )
)

...or if you're using a YAML definition file, then it looks like:
Code:
image:
    class: Image
    label: Upload Image
    params:
        make_thumbnail: true
        height:40
        width:40
        url_path: path/to/image_folder/
        upload_path: ./path/to/image_folder/
        display_name:My Pictures
Using that type of setup, you could probably set it up to take parameters for your image resizing too.

Anyway, I'm glad I could finally help someone Smile I've recieved a lot of help here myself.

cheers
gabriel

[eluser]JamesL[/eluser]
gabriel,

The standard resizing process works fine, I initially setup the form field exactly the way you describe, but I need to create 2 images instead of just one. If you set make_thumbnail: true the script creates a thumbnail with the width and height you provide and leaves the original untouched, or you can tell it to resize the image without creating a thumbnail, then it will overwrite the original image. What I needed to do was overwrite the original image to a new size AND create a smaller thumbnail. So I just altered the image.php script so that it has a two step resizing process, the first resizes the original image to a max of 540px either way, then the second creates a second thumbnail and resizes that image to 40 by 40. You were right on about just modifying the script. If I knew more about OOP and the way CI works I would try to create a new script based on image.php to allow for multiple thumbnail creation and batch image processing, but I'm just getting started with both. Thanks for taking the time to reply to my post, this was a nice introduction to the CI community. Looking forward to working with you in the future.

James

[eluser]JeremyL[/eluser]
[quote author="jTaby" date="1220041558"]by defining a primary_key, just like you defined form_setup and display_fields etc...[/quote]

Can I get some clarification on the format? This is what I am trying

Quote:primary_key:
howto_id

But I get this error when I do

Quote:A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc' at line 3

SELECT `howto_title`, `howto_summary`, `howto_url`, `howto_user_id`, `howto_karma`, `howto_status`, `howto_reports`, `howto_category` FROM (`howtos`) ORDER BY desc

The above format causes the same error is all of my controllers but if I use 'id' in the table and cut that out of the YML file all works great.

[eluser]fender21[/eluser]
This is a question I have as well. What is the syntax for defining the primary_key in the YAML?

[eluser]fender21[/eluser]
JermeyL, after toying with the YAML I found if you put something like this on it's on line in the YAML it will pick up the id column. Hope that helps!

primary_key: artist_id


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.