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>

eZ debug

Timing: Jan 18 2025 16:00:57
Script start
Timing: Jan 18 2025 16:00:57
Module start 'content'
Timing: Jan 18 2025 16:00:58
Module end 'content'
Timing: Jan 18 2025 16:00:58
Script end

Main resources:

Total runtime1.0211 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 587.8281180.8281
Module start 'content' 0.00830.8519 768.6563596.9375
Module end 'content' 0.86030.1608 1,365.5938341.3672
Script end 1.0210  1,706.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.4317210.0002
Check MTime0.00190.1830210.0001
Mysql Total
Database connection0.00110.106910.0011
Mysqli_queries0.919790.07092000.0046
Looping result0.00190.18961980.0000
Template Total0.992697.220.4963
Template load0.00200.195620.0010
Template processing0.990697.011220.4953
Template load and register function0.00020.014810.0002
states
state_id_array0.00070.066610.0007
state_identifier_array0.00160.160620.0008
Override
Cache load0.00190.18601170.0000
Sytem overhead
Fetch class attribute can translate value0.00160.156730.0005
Fetch class attribute name0.00160.155060.0003
XML
Image XML parsing0.00090.084030.0003
class_abstraction
Instantiating content class attribute0.00000.001570.0000
General
dbfile0.00650.6338290.0002
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 30
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs