Share » Forums » General » How to create an image alias...

How to create an image alias automatically?

How to create an image alias automatically?

Friday 13 March 2009 1:20:49 pm - 4 replies

Author Message

André R.

Saturday 14 March 2009 6:42:39 pm

Might help: ezoe generates image sizes for preview on demand, the code is a bit complex:
http://svn.ez.no/svn/extensions/eztinymce/trunk/ezoe/modules/ezoe/load.php
using ezoeajaxcontent.php:
http://svn.ez.no/svn/extensions/eztinymce/trunk/ezoe/classes/ezoeajaxcontent.php

related code (last line in foreach is the one triggering the image generation):

                    $content    = $atr->attribute( 'content' );
                    $imageArray = array();
                    if ( $content != null )
                    {
                        foreach( $params['imageSizes'] as $size )
                        {
                            $imageArray[ $size ] = false;
                            if ( in_array( $size, $params['imagePreGenerateSizes'] )
                                && $content->hasAttribute( $size ) )
                                $imageArray[ $size ] = $content->attribute( $size );
                        }
                        $ret['image_attributes'][] = $key;
                    }

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pawel Graczyk

Sunday 15 March 2009 4:22:30 am

Wow, it generates JSON as well, Thank You. This code is very helpful. :)

André R.

Sunday 15 March 2009 5:21:12 am

It can also generate xml if you want to (if you use soap or xslt), and there are some more advance stuff in the ezcore extension if you need more ajax features( see http://projects.ez.no/ezcore ).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Patrick Kaiser

Tuesday 05 May 2009 1:28:56 am

Just in case someone has also problems to use this code:

Make sure you add the ContentClass which has the image attribute you want use to the AvailableImageDataTypes[] under block [ImageDataTypeSettings] settings in site.ini:

[ImageDataTypeSettings]
AvailableImageDataTypes[]=yourCustomClassWithImageAttribute

Then the requested ImageAlias will be created on the first request. Try this in your module:

$ezAjaxOptions = array(
	'dataMap' => array('all'),
	'fetchPath' => false,
	'fetchChildrenCount' => false,
	'dataMapType' => array(),
	'loadImages' => true,
	'imagePreGenerateSizes' => array('yourCustomImageAlias')
);

$node = eZContentObjectTreeNode::fetch( $testNodeId );
$node_reduced = eZAjaxContent::simplify( $node, $ezAjaxOptions );


Best regards,

Patrick

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu