How to create thumb image in typo3 extension developement


For create you thumb image :
First you have to create Instance

$this->cObject	= t3lib_div::makeInstance('tslib_cObj');
$img = array();
$img['image.']['file.']['height']  = 330;
$img['image.']['file.']['width']   = 940;
#$img['image.']['file.']['maxH']   = 330;
#$img['image.']['file.']['maxW']   = 940;
$img['image.']['file.']['params']  ='-quality 100';
$img['image.']['titleText']        = "Title Text";
$img['image.']['altText']          = "Alter Text";
$img['image.']['file']             = "uploads/tx_jscontentslider/jainish.png";  // Your image path

Below code is render direcly image HTML code

echo $this->cObject->IMAGE($img['image.']);

Output :

<img width="940" height="330" title="Title Text" alt="Alter Text" src="typo3temp/pics/jainish_01_9a7a54d707.jpg" />

If you want only image src then you have to use below code

echo $this->cObject->IMG_RESOURCE($img['image.']);

Output :

typo3temp/pics/jainish_01_9a7a54d707.jpg

If you want to resize the image size depend on height and width then you have to use below code

$img['image.']['file.']['maxH']	= 330;
$img['image.']['file.']['maxW']	= 940;

Instead of

$img['image.']['file.']['height']	= 330;
$img['image.']['file.']['width']	= 940;

Below code is use for create thumb with best quality

$img['image.']['file.']['params']   ='-quality 100';

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

One thought on “How to create thumb image in typo3 extension developement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s