7 Replies Latest reply on Oct 31, 2012 1:45 PM by Nixtev

    Tutorial Announcement : Upload & Resize Image: setting the image width on the fly

    Günter Schenk Level 4
      Hi folks,

      I just published another fully-fledged tutorial which should be of interest to those developers who´d like to know if it´s possible to access and manipulate ADDT´s server behaviours from the "outside" rather than taking the generated code for granted.

      What is this one all about ?

      Those who are familiar with ADDT´s "Upload and Resize Image" server behaviour know that any uploaded image will always be resized according to the previously defined static values -- but what if you´d rather prefer to assign a user-defined value for e.g. the width everytime you´re uploading an image, say by entering "200" into an additional text field of your form ?

      This tutorial will show you ways to do just that, and the URL is: http://www.guenter-schenk.com/tutorials/tutorial.php?id=12

      Cheers,
      Günter Schenk
      Adobe Community Expert, Dreamweaver
        • 1. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
          mrcharis2003@yahoo.c Level 1
          Hi there Gunter

          Great tutorial

          I have followed all your steps exactly ... I think ...

          But.... cant get it to work ......

          I am following the second example solution 2: using a PHP function

          I assume that I should make the code on upload pic form to be exactly the same as the code you wrote

          by pasing the code that you gave to download directly above the trigger exactly as illustrated and then copy the code in the smaller box below and insert it into the trigger

          I am pretty sure I have done it all correctly but it still not work

          I have also added two more fields for a thumb and tooltip image

          My results can be found at

          http://peterscheid.com/guntertutoriallistpic.php

          Please check it out .... hover over the pics and check out the tooltips .....

          I added the other fields to show why I want to get my show thumbnail behavior working..... having three sized images from one field upload is a great big bonus and way more professional (can't ask users to upload the same pic three times .... imagine the form has five pics, thats 15 upload fields )

          Anyway the code in my upload form is as follows ... I think it is exactly the same

          //end Trigger_FileDelete trigger
          function addt_upload_setimagewidth($fieldname,$maximal_width,$default_width) {
          if (!empty($_POST[''.$fieldname.'']) && ctype_digit($_POST[''.$fieldname.'']) && ($_POST[''.$fieldname.''] <= "".$maximal_width."") ) {
          $new_imagewidth = trim($_POST[''.$fieldname.'']);
          }
          else {
          $new_imagewidth = "".$default_width."";
          }
          return $new_imagewidth;
          }
          //start Trigger_ImageUpload trigger
          //remove this line if you want to edit the code by hand
          function Trigger_ImageUpload(&$tNG) {
          $uploadObj = new tNG_ImageUpload($tNG);
          $uploadObj->setFormFieldName("pic_main");
          $uploadObj->setDbFieldName("pic_main");
          $uploadObj->setFolder("images/");
          $uploadObj->setResize("true",addt_upload_setimagewidth("imagewidth",240,250), 0);
          $uploadObj->setMaxSize(1500);
          $uploadObj->setAllowedExtensions("gif, jpg, jpe, jpeg, png");
          $uploadObj->setRename("auto");
          return $uploadObj->Execute();
          }
          //end Trigger_ImageUpload trigger

          Could you please take a quick look at this code and tell me if it looks alright

          If you have time check out my example of your tutorial

          Thanks for all your help always

          Have a great day
          • 2. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
            Hi Gunter,

            great tutorial.

            I was searching for something similar but for image quality on resizing.
            I.e.: decide the quality (from 1 to 100) when uploading a single image.
            I found very annoying to search for the quality setting in the ADDT code.

            Ciao ;).

            tony
            • 3. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
              Günter Schenk Level 4
              Hi charis,

              ------
              addt_upload_setimagewidth("imagewidth",240,250)
              ------

              when looking at the source code of the form, the "Width For Main Pic" text input field has been named "width_pic_1" -- you will have to reference this field name within the function and not the non-existing "imagewidth"

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
                Günter Schenk Level 4
                Ciao Tony,

                ------
                I was searching for something similar but for image quality on resizing.
                I.e.: decide the quality (from 1 to 100) when uploading a single image.
                I found very annoying to search for the quality setting in the ADDT code
                ------

                I fear that you´re out of luck with this, as the image quality is not exposed as a changeable parameter within the generated ImageUpload code

                Cheers,
                Günter Schenk
                Adobe Community Expert, Dreamweaver
                • 5. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
                  mrcharis2003@yahoo.c Level 1
                  Hi there gunter

                  Thanks for your help

                  I followed your instructions and it works.........

                  nearly .......

                  I works perfectly and resizes the picture .... if there is only one picture in my dynamic list ...... (not much of a list)

                  When I add more pics strange things happen when I click on any of the pics it goes to the previous detail page and will only display that detail page nomater what image I click ....

                  it maay be an isure with the dynamic list .....

                  I will try again with a simple dynamic table... see what happens

                  i will start again tomorrow from the beginning and then try your first method and let you know if it works

                  Check out my Example again at

                  http://peterscheid.com/guntertutoriallistpic.php

                  if you have time

                  add a pic and then you will see pretty quick what the problems are very strange

                  But .....
                  Cheeeeers really great tutorial easy to follow ... easyish

                  Have a great day
                  • 6. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
                    Günter Schenk Level 4
                    Hi charis,

                    ------
                    When I add more pics strange things happen when I click on any of the pics it goes to the previous detail page and will only display that detail page nomater what image I click ....

                    it maay be an isure with the dynamic list .....
                    ------

                    I suggest to not discuss these issues in this thread, because they are not related to my tutorial. However it looks as if you´re having some serious issues within the Dynamic List´s recordset -- just hover the mouse over any picture and look at the link that´s displayed in the browser´s status bar: they all have the same "id_pic" value, what certainly can´t be correct.

                    -------
                    I will try again with a simple dynamic table... see what happens
                    ------

                    in case you run into further issues with this, please start a new thread for discussing related things there.

                    Cheers,
                    Günter Schenk
                    Adobe Community Expert, Dreamweaver
                    • 7. Re: Tutorial Announcement : Upload & Resize Image: setting the image width on the fly
                      Nixtev

                      Hi Günter, I know this is a very old thread by now but should solution 2 still work?

                      I've tried using your code and also another method of just replacing the the size value with a recordset value so I get

                       

                        $uploadObj->setResize("true", $row_Rs_gallerysize['photosize_photogallery'], 0);

                       

                      instead of

                       

                        $uploadObj->setResize("true", 500, 0);

                       

                      but both methods just skip past the dynamic value. Yours resizes to the default width and mine doesn't resize at all so I'm wondering if I'm doing something wrong, or if this is just outdated and doesn't work any more?

                       

                      Many thanks,

                       

                      Nicky