Reputation: 25237
What is the equivalent of this Typoscript in PHP?
10 = IMAGE
10.file{
width = 400
height = 300
import = uploads/pics/
import.field = image
}
I'm guessing there is something in TYPO3 libraries that does the same. I have Imagemagick installed.
Upvotes: 1
Views: 1952
Reputation: 55798
In pi1 class of your ext:
$mediaArray = explode(',', $row['media']);
$imgConf = array();
$imgConf['file'] = 'uploads/media/'.$mediaArray[0];
$imgConf['altText'] = $row['nav_title']?$row['nav_title']:$row['title'];
$imgConf['file.'] = $conf['somePreset.']['file.'];
$image = $this->cObj->IMAGE($imgConf);
in TypoScript template:
plugin.tx_myext_pi1.somePreset.file {
maxW = 320
maxH = 130
}
You can also set the dimensions directly in PHP by replacing:
$imgConf['file.'] = $conf['somePreset.']['file.'];
with inline array()
:
$imgConf['file.'] = array(
'maxW' => '320',
'maxH' => '130',
);
Upvotes: 1
Reputation: 23110
It depends on your TYPO3 configuration (in Installer tool). It either uses ImageMagick (or GraphicsMagick) (which are external tools), or GD2 (which is a PHP lib usually included on PHP installation).
To see examples of image resizing, ask Google. There are a lot of examples available.
Upvotes: 0