Reputation: 337
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.
Upvotes: 4
Views: 3295
Reputation: 9671
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:
typo3conf
or fileadmin
, e.g. fileadmin/myimages/
, protect the directory content via .htaccess
cObject
. Upvotes: 1