简体   繁体   中英

TYPO3: cObj->IMAGE not generating image

I have an extension, where I need to generate thumbnails. For this, I wrote kind of a 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, as long as I use a path relative to the TYPO3-Directory: Like: ../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, no picture is generated anymore and " return $cObj->IMAGE($imgTSConfig) " returns NULL.
/var/www/vhosts/domain.com/httpdocs/path/to/picture/c.example.hq.jpg
This path is outside the TYPO3-Install-Directory - but is included within 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 readable from my extension - and it returned true.
Image Processing in the Install Tool works fine.

Do you have any idea, what else I could test? Or am I missing something essential?

Btw: I'm running TYPO3 4.6.1 and PHP 5.3.

SOLUTION:
Make a Symlink within Web-Directory to the external path. This Symlink has to be either within fileadmin/ or typo3conf/
See also konsolenfreddy's Post.

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

If you want to have an image outside your document root, two ways come to mind:

  1. put a symlink in a directory within typo3conf or fileadmin , eg fileadmin/myimages/ , protect the directory content via .htaccess
  2. Use the Gifbuilder function directly. This might be cumbersome and might disable some higher level caching in the cObject .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM