6 Replies Latest reply on Oct 22, 2009 3:49 PM by Ryan Pratt

    thumbnails need a new home and name!

    Ryan Pratt

      Hello world. I am trying to figure out two issues im having.

       

      1. i need to have the thumbnails save to a diffrent directory. they now save in the same directorey as the large image in a folder called thumbnails. I need them to save one directory back and in a folder called thumbnais.

       

      2. i need the thumbnails to save without the size being apended. so image_50_50.jpg  should be image.jpg.

       

      Please help a brother out. I have looked throught all the dependent files and scripts i can think of but cant figure out how to make this work or where the code is for me to mod.

       

      Thanks in advance.

        • 1. Re: thumbnails need a new home and name!
          Günter Schenk Level 4

          Hi Ryan,

           

          while the first "saving to a different directory" issue may be tricky to solve, the other one should be much easier:

           

          1. open the file "includes/tng/triggers/tNG_DynamicThumbnail.class.php" and scroll down to the very last function named Execute()

           

          2. in here you´ll see two instances of the variable $thumbnailName with slightly different values, but which all have the image width and height embedded in the to-be-generated thumbnail name.

           

          Please try with modifying the two variable instances as mentioned next, and please backup the original file first

           

          instance 1

           

          before:

           

          $thumbnailName = $path_info['filename'].'_'.$width.'x'.$height.(isset($path_info['extension'])?'.'.$path_i nfo['extension']:'');

           

          after:

           

          $thumbnailName = $path_info['filename'].(isset($path_info['extension'])?'.'.$path_info['extension']:'');

           

          instance 2

           

          before:

           

          $thumbnailName = $path_info['filename'].'_'.$width.'x'.$height.'_w_'.$hash.(isset($path_info['extension']) ?'.'.$path_info['extension']:'');

           

          after:

           

          $thumbnailName = $path_info['filename'].$hash.(isset($path_info['extension'])?'.'.$path_info['extension']: '');

           

           

          Cheers,

          Günter

          • 2. Re: thumbnails need a new home and name!
            Günter Schenk Level 4

            the term "extension" may of course not have any spaces added in between -- it´s the forum software which appears to insert them for whatever reason

             

            Cheers,

            Günter

            1 person found this helpful
            • 3. Re: thumbnails need a new home and name!
              Ryan Pratt Level 1

              Thank you Gunter,

              I have successfully fixed the renaming of the file. Thanks for the insight. Have any idea how i can get the thumbnails to save back one directory?

               

              I would like to have

              albums/1/large & albums/1/thumbnails

               

              not

               

              albums/1/large & albums/1/large/thumbnails.

               

              Thanks again for your help.

              • 4. Re: thumbnails need a new home and name!
                Günter Schenk Level 4

                Hi Ryan,

                 

                I would like to have

                albums/1/large & albums/1/thumbnails

                 

                not

                 

                albums/1/large & albums/1/large/thumbnails

                I just found a solution which should work for you too, and it´s a tiny variable modification within that - already modified - function Execute().

                 

                before:

                 

                $thumbnailFolder = $path_info['dirname'] . '/thumbnails/';

                 

                after:

                 

                $thumbnailFolder = dirname(dirname($path_info['dirname'])) . '/thumbnails/';

                 

                The trick is to use two nested "dirname" functions, what will actually return the parent directory of $path_info['dirname'] (aka the directory where the "normal" image has been uploaded to, aka "large").

                 

                Cheers,

                Günter

                • 5. Re: thumbnails need a new home and name!
                  Günter Schenk Level 4

                  Günter Schenk wrote:

                   

                  $thumbnailFolder = dirname(dirname($path_info['dirname'])) . '/thumbnails/';

                  oops sorry, please forget about the function nesting I mentioned -- one instance will be enough:

                   

                  $thumbnailFolder = dirname($path_info['dirname']) . '/thumbnails/';

                   

                   

                  I´m still struggling with one issue though: the thumbnail images are now indeed saved in the parent directory´s "thumbnails" subfolder, but it seems some further modification of the function Execute() is required, because right now a page which contains the "Show Thumbnail" server behaviour doesn´t yet retrieve the thumbnails from the customized $thumbnailFolder - location.

                   

                  Cheers,

                  Günter

                  1 person found this helpful
                  • 6. Re: thumbnails need a new home and name!
                    Ryan Pratt Level 1

                    I have just been using the file path and the file name from the db to display thumb. and not using the thumb to display just to create. Not ideal but works for now. I have not tried you fix but will tonight. Thanks for all the help.