Does anyone know in which file I can find getImage function?
Does anyone know in which file I can find getImage function?
Hi Gary,
I think it is in the system/libraries/Controller.php
Regards,
Paul
Many thanks Paul.
Hi Gary,
This might be useful too... http://api.typolight.org/Controller/...methodgetImage
Regards,
Paul
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 :-(
The $mode is new to 2.8, it basically adds more resizing options. See this comment in ticket #1219.
you can use the getImage hook available since version 2.8rc1 if you need to implement custom logicOriginally Posted by Doublespark
see ticket 662
Consulenza Contao CMS https://www.intco.it
I think I am getting closer.
I have replaced:
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; }
There is something wrong with my code as this causes a wobbly and a white page.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;
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.
You can actually edit the line which checks for the GD version. Just add another condition that prevents getImage() from using the GIF extension.
Hi Gary,Originally Posted by Doublespark
if you can use the 2.8rc version of TYPOlight just do the following:
- add your getImage hook to config.php
- write your hookCode:$GLOBALS['TL_HOOKS']['getImage'][] = array('MyClass', 'dontResizeGif');
if you can't use the 2.8rc version replace the code you posted with: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; } }
please note that the above code is untestedCode:if ($objFile->extension == 'gif') { $this->import('Files'); $this->Files->copy($image, $strCacheName); return $strCacheName }
Consulenza Contao CMS https://www.intco.it
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
But I'd much rather use the config method if at all possible.Code:if ($objFile->extension == 'gif') { return $image; }
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.)
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.
Bookmarks