TYPO3: cObj-> IMAGE does not generate an image

I have an extension where I need to create thumbnails. For this, I wrote some wrapper function.

public static function pictureGenerator($file, $title, $size_w, $size_h) { $cObj = t3lib_div::makeInstance('tslib_cObj'); $imgTSConfig = array(); $imgTSConfig['file'] = $file; $imgTSConfig['file.']['width'] = $size_w . 'm'; $imgTSConfig['file.']['height'] = $size_h . 'm'; $imgTSConfig['altText'] = empty($title) ? 'preview' : $title; $imgTSConfig['titleText'] = empty($title) ? 'preview' : $title; return $cObj->IMAGE($imgTSConfig); } 

This function works fine while I use the path relative to TYPO3-Directory: For example: ../ typo3conf / ext / sd_filmbase / res / images / default_film.jpg

But as soon as I try to use an absolute System-Path like the one below, the image is no longer generated and "return $ cObj-> IMAGE ($ imgTSConfig)" returns NULL.
/var/www/vhosts/domain.com/httpdocs/path/to/picture/c.example.hq.jpg
This path is outside of TYPO3-Install-Directory - but is included in open_basedir (and safe_mode is Off).

I added the following path to open_basedir: /var/www/vhosts/domain.com/httpdocs/path/
And I tested with is_readable () if the file is read from my extension - and it returned true.
Image processing in the setup tool works great.

Do you have any ideas what else I could check? Or am I missing something substantial?

Btw: I am running TYPO3 4.6.1 and PHP 5.3.

DECISION:
Make Symlink in the Web Directory an external path. This symlink should either be in fileadmin / or typo3conf /
See also post konsolenfreddy.

+4
source share
1 answer

The IMAGE function always expects a file relative to PATH_site in either fileadmin or fileadmin (see getFilename in t3lib_tstemplate ).

If you want to have an image outside your document root, you have two options:

  • places a symlink in the typo3conf or fileadmin , for example. fileadmin/myimages/ , protect the contents of the directory with .htaccess
  • Use the Gifbuilder function directly. This can be cumbersome and can disable higher-level caching in cObject .
+1
source

Source: https://habr.com/ru/post/1386814/


All Articles