Results 1 to 14 of 14

Thread: Where is the getImage function

  1. #1
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Where is the getImage function

    Does anyone know in which file I can find getImage function?

  2. #2
    User
    Join Date
    09-25-09.
    Location
    Amsterdam, The Netherlands
    Posts
    103

    Default Re: Where is the getImage function

    Hi Gary,

    I think it is in the system/libraries/Controller.php

    Regards,
    Paul

  3. #3
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: Where is the getImage function

    Many thanks Paul.

  4. #4
    User
    Join Date
    09-25-09.
    Location
    Amsterdam, The Netherlands
    Posts
    103

    Default Re: Where is the getImage function

    Hi Gary,

    This might be useful too... http://api.typolight.org/Controller/...methodgetImage

    Regards,
    Paul

  5. #5
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: Where is the getImage function

    Thanks Paul.

    string getImage (string $image, integer $width, integer $height, [string $mode = ''], [string $target = null])

    I wonder what $mode is all about?

    Looks like I might have to give up on the animated gif idea :-(

  6. #6
    User FloB's Avatar
    Join Date
    06-21-09.
    Posts
    157

    Default Re: Where is the getImage function

    The $mode is new to 2.8, it basically adds more resizing options. See this comment in ticket #1219.

  7. #7
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Where is the getImage function

    Quote Originally Posted by Doublespark
    Thanks Paul.

    string getImage (string $image, integer $width, integer $height, [string $mode = ''], [string $target = null])

    I wonder what $mode is all about?

    Looks like I might have to give up on the animated gif idea :-(
    you can use the getImage hook available since version 2.8rc1 if you need to implement custom logic

    see ticket 662
    Consulenza Contao CMS https://www.intco.it

  8. #8
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: Where is the getImage function

    I think I am getting closer.

    I have replaced:
    Code:
    		// Check file type
    		if (!in_array($objFile->extension, $arrAllowedTypes))
    		{
    			$this->log('Image type "' . $objFile->extension . '" was not allowed to be processed', 'Controller getImage()', TL_ERROR);
    			return null;
    		}
    with:
    Code:
                    // Check file type
                    if (!in_array($objFile->extension, $arrAllowedTypes))
                    {
                            $this->log('Image type "' . $objFile->extension . '" was not allowed to be processed', 'Controller getImage()', TL_ERROR);
                            return null;
                    }
    
                                    if(strtoupper($objFile->extension) == 'GIF')
                                    {
                                            list($width, $height, $type, $attr) = getimagesize(TL_ROOT . '/' . $image);                                     
                                    }
    
                                    $strCacheName = 'system/html/' . $objFile->filename . '-' . substr(md5('-w' . $width . '-h' . $height . '-' . $image . '-' . $mode), 0, 8) . '.' . $objFile->extension;
    There is something wrong with my code as this causes a wobbly and a white page.

    The idea is to hack the image resizer so that it does not process gifs.

    PHP is really not my thing, any help much appreciated.

  9. #9
    User FloB's Avatar
    Join Date
    06-21-09.
    Posts
    157

    Default Re: Where is the getImage function

    You can actually edit the line which checks for the GD version. Just add another condition that prevents getImage() from using the GIF extension.

  10. #10
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Where is the getImage function

    Quote Originally Posted by Doublespark
    The idea is to hack the image resizer so that it does not process gifs.
    Hi Gary,

    if you can use the 2.8rc version of TYPOlight just do the following:

    - add your getImage hook to config.php
    Code:
    $GLOBALS['TL_HOOKS']['getImage'][] = array('MyClass', 'dontResizeGif');
    - write your hook
    Code:
    // this must be put in a file named MyClass.php
    class MyClass extends Controller {
        public function dontResizeGif($image, $width, $height, $mode, $strCacheName, $objFile) {
             if ($objFile->extension != 'gif') {
                  // i.e. let TYPOlight process the image as usual
                  return null;
             }
             // copy the image "as is" to the cache
            $this->import('Files');
            $this->Files->copy($image, $strCacheName);
            return $strCacheName;
        }
    }
    if you can't use the 2.8rc version replace the code you posted with:

    Code:
    if ($objFile->extension == 'gif') {
            $this->import('Files');
            $this->Files->copy($image, $strCacheName);
            return $strCacheName
    }
    please note that the above code is untested
    Consulenza Contao CMS https://www.intco.it

  11. #11
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: Where is the getImage function

    Thanks, ga.n and FloB

    I am using 2.8RC2, but could not get that to work, I tried putting MyClass.php in both /templates/ and /system/config - is that the right place? It does not seem to have any effect in either of these.

    Also, did you mean add the hook to config.php or localconfig.php, if I add to to config.php, it has no effect, if I add it to localconfig.php I get a blank screen.

    Thanks to your help I have have managed to hack controller.php by adding this on line 724
    Code:
    		if ($objFile->extension == 'gif') {
            return $image;
    		}
    But I'd much rather use the config method if at all possible.

  12. #12
    User FloB's Avatar
    Join Date
    06-21-09.
    Posts
    157

    Default Re: Where is the getImage function

    You have to place the File into either "/system/libraries/" or "/system/modules/nogif/". The hook can either be activated by placing the code into "/system/config/dcaconfig.php" or "/system/modules/nogif/config/config.php". (I'd use the latter method for both. You can choose any other module folder name.)

  13. #13
    User
    Join Date
    06-19-09.
    Posts
    417

    Default Re: Where is the getImage function

    Thanks for your help Flob, it works a treat! :-)

    What's great is I do not have to edit controller.php, so no issues when I come to upgrade :-)

    You have also taught me more about how TL works and ways in which it can be customised, which will be handy in the future.

    I really appreciate both your and ga.n's help with this, really appreciated!

    Cheers, Gary.

  14. #14
    User FloB's Avatar
    Join Date
    06-21-09.
    Posts
    157

    Default Re: Where is the getImage function

    You're welcome

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •