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 » Image variation in custom embed template

Image variation in custom embed template

Image variation in custom embed template

Friday 20 March 2015 3:50:14 pm - 8 replies


I'm sorry if this is the wrong subforum to post this in, in which case, feel free to move it.

I'm currently working on a project in which I need to override the template for embedded images in an XML-block, and for my template I need to know which image alias/variation the user has chosen when an image is embedded in the online editor.

I can't, however, seem to find any data telling me which is chosen in the template. I can only find the original image. How would I go about getting the variation name in the template? I'm currently using version 5.4.


Saturday 21 March 2015 7:33:02 pm

Hello Mads,

Welcome to the eZ Community!

Lets together look at the template used in question using a default ezwebin based installation,

It's worth mentioning here that the above template could be different in your unique installation depending on which default design extension you use (ezdemo / ezwebin / completely custom) and which template is used is usually customized in siteaccess override.ini.append.php rules.

In ezwebin these are installed using the setup wizard but here they are in code form,

Sorry, I can't link to them in ini settings form since they don't exist in that way until after installation.

In any case as you can tell reading the above embed image template the actual code is abstracted and actually (usually) lives in this template:

Now if you follow the code execution path (in reverse) you'll notice that the image variation alias image parameters are rendered in code here:

The image variation alias selection at it's lowest level of rendering (in this use case) happens here:

Notice that template variable (for this template) representing the name of the image alias is 'image_class' which defaults to a value of 'large' (not original) if the parameter is not passed when this template is included.

Now lets back up to the first template where the ezimage.tpl template is included (indirectly via attribute_view_gui)

Notice that on the line I linked to in the first 'else' case on the same line is the following code:

{attribute_view_gui attribute=$object.data_map.image image_class=$object_parameters.size border_size=first_set( $object_parameters.border_size, '0' ) border_color=first_set( $object_parameters.border_color, '' ) border_style=first_set( $object_parameters.border_style, 'solid' ) margin_size=first_set( $object_parameters.margin_size, '' )}

Now we could talk for a long time about all of these details but the important part for you to understand is that the image alias name as I mentioned before is passed as the variable 'image_class' in the above code snippet example you see that the value within the scope of the 'embed' template (for images) is provided by the 'size' variable within the 'object_parameters' variable.

You should be able to use the 'object_parameters' within any custom embed image template code. 

Even if you do not use ezwebin or ezdemo design extensions this base functionality is provide using the base design template overrides (which provide another possible use case example of this functionality):

If you have more questions please feel free to ask here in the forums and we will be happy to help!

I hope this helps!


Modified on Saturday 21 March 2015 7:35:46 pm by // Heath

Saturday 21 March 2015 11:16:56 pm

Or maybe you're using twig templates & Symfony ? In which case these might not be the links you need happy.gif Emoticon

Sunday 22 March 2015 4:44:37 am


Snippy comments are my thing™ //kracker  ... besides you could have actually shared some helpful information to help the user instead of nocking on Heath for answering a (possible) legacy question in a legacy forum. It's really up to the user to share upfront the version / stack the question is related to / about ... 

"Everywhere I go, all I seem to hear is ..." (Que the theme, that means listen to the song and re-read the thread .. fools)


THEME: Dr. Dre : Chronic 2001 : Bang Bang ...

Sunday 22 March 2015 5:06:42 am


As Bertrand highlights, I should have asked first, What version of eZ are you using, also what stack?

As //kracker suggests (indirectly as always) if a post is made in the ez5 forum then we know it's ez5 related otherwise these days we are left guessing legacy by default or asking the OP.

In new stack the solution is very similar in style and function.

Consider the use in the DemoBundle:

Which also uses:

After reading ezimage_simple.html.twig I can honestly say I think that Bertrand is right that Mads was asking about new stack usage in twig because in the above link if you read the code you can see the default image alias used if a parameter is not passed is the 'original' image alias; Which is a different default behavior than in ezwebin legacy (at least) where large alias is used instead which I highlighted above.

In any case within 'Resources/views/embed/image.html.twig' notice that objectParameters.size is the variable providing the alias name.

This is defined in new stack using yml here:

Kudos to Bertrand on the find. Props to //kracker for the defend. +1 for more detailed and informative posts and much love to the eZ Ecosystem! "Still ... taking my time to perfect the beat and I still got love for the streets!" - Still D.R.E

I hope this helps!


PS: @kracker this one is still one of my favorites, I think it's eerily relevant these days, don't you? blunk.gif Emoticon

Modified on Sunday 22 March 2015 5:08:16 am by // Heath

Sunday 22 March 2015 5:52:42 am

Not that anyone here cares but ..

It seems that objectParameters variable comes from here:

Which seems to be called indirectly just above this point:

Which then calls this:

Just another Public Service Announcement blunk.gif Emoticon

This thread is toasted with both stacks covered! Now let the album play ..


THEME: Eminem : The Marshall Mathers LP : Public Service Announcement

[Announcer: Jeff Bass]
This is another public service announcement
Brought to you, in part, by Slim Shady
(Tell 'em I don't give a f*ck)
**Slim Shady does not give a f*ck what you think**
(Tell 'em to suck it)
If you don't like it, you can suck his f*cking glock
(Tell 'em they kissed my ass)
Little did you know, upon purchasing this album, you have just kissed his ass
(Tell 'em I'm fed up)
Slim Shady is fed up with your sh*t, and he's going to skill you
Uh... anything else?

Yeah... sue me!

Wednesday 25 March 2015 11:31:35 am

@Heath, @kracker and @Bertrand,

I am sorry that I wasn't clear enough in the OP, I'll do better at that next time I'm posting something. Thank you @Heath for giving me such great answers for both legacy and the new stack. It is correct that it is the new stack I meant to ask for, and `objectParameters.size` is exactly what I was looking for, yet didn't see when I looked for it - I should have done a better job at doing research before posting the question.

I am also sure the answer for the legacy stack will come in handy at a later point.

Thank you all very much,

Mads Røskar

Thursday 26 March 2015 6:37:55 am

Hello Mads,

I'm happy we could help you find the solution you needed!

Can you login to, come back to this thread once logged in and then click the checkbox at the top of your original post just to the left / near the title of your post? It is the grey image icon with the checkbox inside. It turns green when you have clicked it correctly.

Doing this indicates your question has been solved.

Thanks again for your continued support!

Take it eZ!


Monday 30 March 2015 6:28:44 am

The reply has been removed because of violation of forum rules.


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

36 542 Users on board!

Forums menu

Proudly Developed with from