This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » pregenerate image alias on object...

pregenerate image alias on object publishing

pregenerate image alias on object publishing

Monday 24 October 2011 1:02:18 am - 14 replies

Is there some way to pregenerate all aliases of an image when an object with image attribute is published?

As far as I checked only "small" and "reference" aliases are generated upon object publishing? Is this hardcoded somewhere or it can be setup somewhere?

Monday 24 October 2011 8:49:11 am

Hello Marko,

I think you're looking for this piece of code:

 $img = eZImageManager::instance();
 $img->convert( $file, $destinationMimeData, $aliasName )

Check ez api for more info

Monday 24 October 2011 8:55:32 am

Hello Marko,

While answering this related thread [0] I created a command line script [1] and then a workflow event [2] which I think does what your asking for ...


I hope this helps ...



Modified on Monday 24 October 2011 8:57:52 am by // Heath

Monday 24 October 2011 10:25:22 am


Just to notice, 'cause i had an issue, be careful that you have enought right on your account (for example a chroot account) to run php command like :

 system( "convert .... "     );

Small tip blunk.gif Emoticon


Monday 24 October 2011 4:30:35 pm

And how about making this a feature of eZP?

It looks like a good candidate for a community roadmap item...

Monday 24 October 2011 5:11:35 pm


I think I really agree with you here on this idea. I think this has value to other users.

Would you take the initiative and publish a new community roadmap entry on this topic?

I would also link to these recent threads as a reference within the roadmap entry text.


Thank you for your continued support!




Monday 24 October 2011 6:15:20 pm

Ok, I've added the request to roadmap, waiting for approval...

Monday 24 October 2011 6:32:33 pm

Hello Marko,

Thank you again for your help.

I see the roadmap feature request is now in moderation (currently) here,




Tuesday 25 October 2011 6:05:09 am

Hello Everyone,


I have made quite a few improvements to the example script and workflow event.


Apologies for the (to numerous number of) previous mistakes, bugs, typos, etc.


Perhaps I should just turn this into a project at this point?Polish off a complete working standalone extension?


I still think this requires more testing.Having a complete extension would help make that testing and refinement a whole lot simpler than a wiki pastebin example.


I await your thoughts ...




Modified on Tuesday 25 October 2011 6:08:33 am by // Heath

Tuesday 25 October 2011 8:26:20 am

I suggest we wait for the feature request to be approved in the roadmap and then put it into the branch of eZP where it will be developed.

Monday 31 October 2011 4:49:53 am

Hello Marko,

I'm afraid I must respectfully disagree with your suggestion on direction.

I believe that the community should step up and provide example implementations of solutions to community roadmap feature requests before eZ Systems or the community board takes action on a roadmap request.

Which is why over the weekend I have re-implemented the entire solution previously shared through

Brookins Consulting is proud to announce the release of BC ImageAlias!

I have published this new version tonight. The new extension bcimagealias is a ready to use (right out of the box), well documented, complete and flexible extension based solution.

The packaged extension downloads are also available,

We have provided the follow within the extension bcimagealias

- Generic PHP class
- Command line scripts
- Workflow event
- CronJob

This packaged, complete extension provides a wide range of tools to use to generate and remove image alias image variation image files quickly, efficiently and effectively.

While the extension is light years beyond the initial example wiki implementation it may still need improvement and refinement. This is after all only the second published version. Current version 0.0.20

I suggest anyone trying to base a solution on the untested and now deprecated wiki article based source code examples to abandon this code as incomplete and ultimately not effective (enough) out of the box.

The bcimagealias extension was heavily tested with the latest 2011.09 build and works right out of the box. Surprisingly it is already quite stable. A special focus was given during development to ease of use. The extension is very user friendly to use.

We have documented some interesting FAQ items in the documentation provided with the extension


We also would like to encourage anyone with questions or comments feel free to post a message in the project forums.

Thanks again for your continued support! Enjoy generating and removing your image alias image variation image files!




Modified on Monday 31 October 2011 5:49:13 am by // Heath

Thursday 08 December 2011 7:23:00 am

Hello Marko!


After a whole lot of development and testing I wanted to share two key things tonight.


In response to your first forum message

First, in your first forum message in this thread you mentioned were or might be generated on publish. This statement is inaccurate. What you saw was the aliases generated after viewing a node using the content/view module view (siteaccess not specific in this case) after the node was published.

I know because I re-created these exact events while working on bcimagealias and had to figure out exactly why it occurred during development.

Again to be clear only the original image alias is created on when object / node published and no other image aliases -at all-.

If you use the bcimagealias workflow event you can generate the image alias image variation files on the 'content, publish, after' trigger which is called / run just after the node is published but before users can request the generation of the image aliases on the filesystem/in eZ.

Which we think is the soonest you can create image aliases in the system by default as these aliases seem to be bound to the parent node names in the uri to the variation image file(s) generated in the var directory.

If you do not use the workflow event, image aliases will be created normally on the fly, dynamically as they are requested / used within templates used on a given request.


New features in BCImageAlias

Also I wanted to take a moment to share that we have recently pushed changes tonight which add new features to the bcimagealias extension which allows it to now generate content tree node object and all child node object image aliases via PHP, cli script and workflow event.

Previous versions of the extension were limited to generating by object-id (one object at a time). The new version allows for generation by node-id and optionally child node subtree(s) (many objects at one time).

This is the most common use case we see for new users of the extension and we are very happy to see these new features land in the project repository (among many other smaller improvements).

This means you can simply install the extension and very quickly generate all image aliases in the content tree(s)('Home', 'Media', 'Users' root node subtrees, in default install of ezwebin) directly, quickly and efficiently in one easy to use command line command.


We are not yet regularly reposting packages as the extension development continues at a more frequent pace. In the future after the next few waves of feature development we will establish a more regular release and package routine so users who don't use git just yet can always try the latest stable version.

As always you can still get the latest stable tested beta extension sources from github directly,

And here is a copy of the latest version's changelog and the recent commit described above.


Feel free to ask more questions about bcimagealias, we would be happy to answer your questions!


I hope this helps ...




Modified on Thursday 08 December 2011 7:23:31 am by // Heath

Sunday 11 December 2011 6:32:05 pm

Hello Marko and the rest of the eZ Community!


After a whole lot of development and testing I wanted to share some new developments today.

Today we have pushed a rather large set of improvements for bcimagealias extension to GitHub,

New features in BCImageAlias

We added admin siteaccess content structure and popup class menu links. These links allow for you to use the same features as the command line script to create, regenerate and remove image alias image variation image files using two new module views 'create' and 'remove'. This was the initial focus for this iteration of development.

This makes it possible for any user with the required role policies to create, regenerate and remove image alias image variation image files using the existing content structure and popup class menus with the bcimagealias extension using the admin siteaccess without any complications.

Also it's worth mentioning we added support to the bcimagealias script and class for the parameters '--classes', '--attributes' and '--aliases'. You can see examples of how to use these parameters reviewing the doc/USAGE file,

You can review the changelog (as we have made many improvements to 0.0.23 version)


We hope this helps ...




Tuesday 04 September 2012 9:17:05 pm

Thanks all for the discussion and initiatives.  I just want to add to this with a more "best practice" image alias file creation code snippet that works in standard setups but also respects the various different file handlers available (such as eZ DFS):

$myObject = eZContentObject::fetch( $objectID );
$dataMap = $myObject->attribute( 'data_map' );
$imageAttribute = $dataMap[ 'image' ];
$imageHandler = new eZImageAliasHandler( $imageAttribute );
$result = $imageHandler->imageAlias( $aliasName );
return $result['full_path'];

Modified on Tuesday 04 September 2012 9:18:26 pm by Peter Keung

Friday 09 June 2017 9:24:48 pm

To add a bit of detail to the snipppet that Peter posted: that code will not work if the file with the image variation is not on disk any more, but the content object attribute has stored in the database the fact that it is there (inside the attribute value) - in that case the image will not be regenerated.

Clearing the image variation cache will not help, either.

The only way to fix the problem is to do a purge of the image variation cache.

Modified on Friday 09 June 2017 9:25:20 pm by Gaetano Giunta


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

36 542 Users on board!

Forums menu

Proudly Developed with from