Customize TYPO3′s image effect’s degrees of rotation

by Michael Cannon in Featured, TYPO3 · 5 comments

Recently, Mark of The Great Books Foundation asked me `Since we never rotate our images 90 degrees, but do rotate them 2 degrees, can we change the Effect drop-down to Rotate 2 and Rotate -2 instead of Rotate 90 and Rotate -90?`

The answer is yes and to save you the near 2 hours of figuring out the solution, mine follows.

Code added to localconf.php

$TYPO3_CONF_VARS["FE"]["XCLASS"]["tslib/class.tslib_content.php"] = PATH_typo3conf . 'class.ux_tslib_content.php';
$TYPO3_CONF_VARS['SYS']['locallangXMLOverride']['EXT:cms/locallang_ttc.xml'][] = PATH_typo3conf . 'locallang.ux_tslib_content.xml';

Code in class.ux_tslib_content.php.

<!--?php <br ?-->/**
 *  Enable alternate image rotation amounts
 *
 *  @author Michael Cannon
 *  @version $Id: .vimrc,v 1.7 2011/07/13 05:23:57 peimic.comprock Exp $
 */
class ux_tslib_cObj extends tslib_cObj {
	function start($data, $table = '') {
		parent::start($data, $table);
		$this->image_effects[ 1 ]	= '-rotate 2';
		$this->image_effects[ 2 ]	= '-rotate 358';
	}
}
?>

Code in locallang.ux_tslib_content.xml.

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
	<meta type="array">
		<description>Custom Labels for image effects</description>
	</meta>
	<data type="array">
		<languageKey index="default" type="array">
			<label index="image_effects.I.1">Rotate 2 CW</label>
			<label index="image_effects.I.2">Rotate 2 CCW</label>
		</languageKey>
		<languageKey index="de" type="array">
			<label index="image_effects.I.1">Drehen 2 CW</label>
			<label index="image_effects.I.2">Drehen 2 CCW</label>
		</languageKey>
	</data>
</T3locallang>

References

  • TYPO3 PHP Class Extension, XCLASS

If your rotated image isn’t rotating and not being displayed at, whether or not the above was applied, check that your localconf.php has `$TYPO3_CONF_VARS['GFX']['im_no_effects'] = ’0′;` set.

Be Sociable, Share!

Related Entries

  • No Related Entries
About Michael Cannon

Hello, I'm Michael Cannon, Peichi's smiling man, an adventurous water-ratchief technology officer, cyclist, poet, WWOOF'er and world traveler.

Previous post:

Next post: