Different imagesizes on images embedded in an XML Text field

Author Message

Tor Olav Steinsvoll

Thursday 24 July 2003 4:11:13 am

I have related an image and put that into an article. When I put it in to the article I decide a size for the image. This is good.

BUT. I have a frontpage where I want my last articles to be shown in different views. Is it a way to decide the imagesize of the embedded image in one template? Let us say that the size of the image is medium and I want that image to show as small in one articleview on the frontpage?

I want this frontpage to be like a newspaper. The last article should be shown with medium-sized image, the others with small-sized images.

I hope someone knows what I have to do to get there

Regards from Tor Olav

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?

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