Different imagesizes on images embedded in an XML Text field

Different imagesizes on images embedded in an XML Text field

Thursday 24 July 2003 4:11:13 am - 5 replies

Author Message

Bjørn Kaarstein

Thursday 24 July 2003 4:36:25 am

Take into account that this is pure speculation...

Your image embedding is probably using embed_class_5.tpl or something like that.

If you assign your frontpage to it's own section, you might be able to write a switch/case or {section show=} based on which section you are displaying your embedded images in. This I think should be written in your embed override.

Regards Bjørn

Jan Borsodi

Thursday 24 July 2003 6:50:24 am

For it's not possible to change the size of embedded objects (images) inside xml fields dynamically. The only way to change the image size is to change the size in the object xml tag, however this doesn't solve the problem with having the first article with a large image.

The best to achieve this is to add a new attribute to the article class which is either an image type or a related object type.
In the view template you could for instance do (if you use image type)
{attribute_view_gui image_class=medium attribute=$object.data_map.image}
for medium images and
{attribute_view_gui image_class=small attribute=$object.data_map.image}
for small images.

For the object relation type you must change the override template for images (for instance embed_image.tpl) to handle this input, for instance

{default image_class='medium'}
{set image_variation=$object.data_map.image.content[$image_class]}
...
{/default}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Tor Olav Steinsvoll

Thursday 24 July 2003 7:59:15 am

I am not sure where to put this code in the embed_image.tpl?

Here is some of the code I got now:

{let image_variation="true"
align="center"
href=''}

{section show=is_set($attribute_parameters.size)}
{set image_variation=$object.data_map.image.content[$attribute_parameters.size]}
{section-else}
{default image_class='medium'}
{set image_variation=$object.data_map.image.content[$image_class]}
...
{/default}

{*set image_variation=$object.data_map.image.content["small"]*}
{/section}

Is this code now OK?

Mvh Tor Olav

Jan Borsodi

Thursday 24 July 2003 8:03:51 am

You need the default tag around the whole template code, to default the value to 'medium' incase it's not specified.

embed_image.tpl:

{default image_class='medium'}
{let image_variation="true"
align="center"
href=''}

{section show=is_set($attribute_parameters.size)}
{set image_variation=$object.data_map.image.content[$attribute_parameters.size]}
{section-else}
{set image_variation=$object.data_map.image.content[$image_class]}
{/section}

{section show=is_set($attribute_parameters.align)}
{set align=$attribute_parameters.align}
{section-else}
{set align="center"}
{/section}

{section show=is_set($attribute_parameters.href)}
{set href=$attribute_parameters.href}
{section-else}
{set href=""}
{/section}

{switch match=$align}
{case match="left"}
<div class="imageleft">
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}

<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{case match="right"}
<div class="imageright">
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}

<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{case}
<div class="imagecenter">
{section show=$href}<a href={$href|ezurl}>{/section}
<img src={$image_variation.full_path|ezroot} />
{section show=$href}</a>{/section}

<div style="width: {$image_variation.width}px;">
{$object.data_map.caption.content.output.output_text}
</div>
</div>
{/case}
{/switch}

{/let}
{/default}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Tor Olav Steinsvoll

Thursday 24 July 2003 8:18:15 am

Thanks a lot. When I look at some of my frontpage.tpl code I got this for one "segment":

{section name=Child loop=$children offset=1 max=3}

<table width="98%" border="0" cellspacing="4" cellpadding="0" align="center">
<tr>
<td><div class="pagetitle">{$Child:item.name}</div></td>
</tr>
<tr>
<td><div class="articleintro">{$Child:item.data_map.intro.content.output.output_text}</div></td>
</tr>
<tr>
<td><a href={concat("/content/view/full/",$Child:item.node_id)|ezurl}>Les mer...</a></td>
</tr>
<tr height="10">
<td height="10"></td>
</tr>
</table>
{/section}

It is in the intro-field that the picture is a object. How do I put the code in to make it small-sized?

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.