Forums / Setup & design / How should i handle images in template ?

How should i handle images in template ?

Author Message

Dominic Mercier

Tuesday 03 October 2006 10:45:39 am

Hello,

I'm new to this engine and i wonder what is the correct way to use images in a template ?
According to the tutorial 'Building an eZ publish site' which seems to be outdated, images are called thumbnails and they're added inside the article. I can't find any section called thumbnail.

I tried to add the link under 'Image' section which can hold only one image. What if i need 2 images ?? Should i use related objects ?? Should i use explicit tag (<img>) in template and use media reference as link ??

I tried all on them, but i've never been able to display a single image...

So how should i manage images in an article. An example on how to display it would be nice too :P

Thanks for your help :)

Łukasz Serwatka

Tuesday 03 October 2006 11:44:23 pm

All image settings you can find in settings/image.ini. File that contains comments, so you should quickly figure out how to add new image aliases and so on. Don't change default file, use global override or per siteaccess. Create new file image.ini.append.php under settings/override or settings/siteaccess/(your_site_access)

If your content class attribute is image datatype then you can display it using

{attribute_view_gui attribute=$node.object.data_map.image image_class=large} where image class equals to aliases in your override image.ini.append.php

See also template design/standard/templates/content/datatype/view/ezimage.tpl for list all available parameters.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Dominic Mercier

Thursday 05 October 2006 12:43:49 pm

I still can't display any image. I must have missed something important.

Here's my template code:

{attribute_view_gui attribute=$node.object.data_map.image image_class=large}
{$node.object.data_map.image|attribute(show, 1)}

Here's the output without any image
<i>
Attribute Type Value
id string 195
contentobject_id string 58
version string 2
language_code string 'eng-CA'
language_id string 2
contentclassattribute_id string 154
attribute_original_id string 0
sort_key_int string 57
sort_key_string string ''
data_type_string string 'ezobjectrelation'
data_text string ''
data_int string 57
data_float string 0
contentclass_attribute object[ezcontentclassattribute] Object
contentclass_attribute_identifier string 'image'
contentclass_attribute_name string 'Image'
can_translate integer 1
is_information_collector string 0
is_required string 0
content object[ezcontentobject] Object
has_http_value boolean false
value object[ezcontentobject] Object
has_content boolean true
class_content array Array(3)
object object[ezcontentobject] Object
object_version object[ezcontentobjectversion] Object
view_template string 'ezobjectrelation'
edit_template string 'ezobjectrelation'
result_template string 'ezobjectrelation'
has_validation_error boolean false
validation_error NULL
validation_log NULL
language object[ezcontentobjectattribute] Object
is_a string 'ezobjectrelation'
display_info array Array(4)
class_display_info array Array(2)
</i>

The object datatype seems to be valid.
There is no warnings or errors in debug
What else can i check ?? :)

Thanks !! :P

Łukasz Serwatka

Thursday 05 October 2006 12:56:17 pm

Hi Dominic,

Your image attribute is ezobjectrelation type, this means that holds relation to other object. You need to access your image like this:

{attribute_view_gui attribute=$node.object.data_map.image.content.data_map.image image_class=large}

So .content holds that related object information.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Dominic Mercier

Friday 06 October 2006 7:29:55 am

Hi, thanks for helping me :)

Guess what.. It still doesn't display the image ><
This seems so basic and i can't generate a tiny img tag ><

Here's my code again :P
<b>Template code</b>

{attribute_view_gui 
attribute=$node.object.data_map.image.content.data_map.image 
image_class=large}
{$node.object.data_map.image.content.data_map.image|attribute(show, 1)}

<b>Output</b>
<i>
Attribute Type Value
id string 188
contentobject_id string 57
version string 1
language_code string 'eng-CA'
language_id string 3
contentclassattribute_id string 118
attribute_original_id string 0
sort_key_int string 0
sort_key_string string ''
data_type_string string 'ezimage'
data_text string ' '
data_int NULL
data_float string 0
contentclass_attribute object[ezcontentclassattribute] Object
contentclass_attribute_identifier string 'image'
contentclass_attribute_name string 'Image'
can_translate integer 1
is_information_collector string 0
is_required string 0
content object[ezimagealiashandler] Object
has_http_value boolean false
value object[ezimagealiashandler] Object
has_content string 1
class_content string ''
object object[ezcontentobject] Object
object_version object[ezcontentobjectversion] Object
view_template string 'ezimage'
edit_template string 'ezimage'
result_template string 'ezimage'
has_validation_error boolean false
validation_error NULL
validation_log NULL
language object[ezcontentobjectattribute] Object
is_a string 'ezimage'
display_info array Array(4)
class_display_info array Array(2)
</i>