How do I check if an image exist

Author Message

Clay Pereira

Monday 22 March 2004 11:23:00 am

Hi,
I'm trying to check to see if an image exist. If it doesn't I don't want to display the section. This is what I have. Why doen't it work.

{section show=ne($node.object.data_map.image.content)}
{attribute_view_gui attribute=$node.object.data_map.image image_class=small alignment=right href=$node.url_alias|ezurl}
{/section}

thank you

Trond Åge Kvalø

Monday 22 March 2004 12:44:41 pm

You are using show=ne(($node.object.data_map.image.content)}

Isn't that the same as saying if there's no image, show the image? Or am I missing something essential here. (It's late and I'm dead tired...)

Anyway here's the "official" method of checking if there's an image. Taken from the "New image system" infopage.

{let content=$node.data_map.image.content}
{section show=$content.is_valid}
    We have an image.
{section-else}
    No image has been uploaded.
{/section}
{/let}

I've used it a lot and it works for me.

best regards
trondåge

trondåge

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

eZ debug

Timing: Jan 19 2025 03:20:37
Script start
Timing: Jan 19 2025 03:20:37
Module start 'layout'
Timing: Jan 19 2025 03:20:37
Module start 'content'
Timing: Jan 19 2025 03:20:38
Module end 'content'
Timing: Jan 19 2025 03:20:38
Script end

Main resources:

Total runtime1.1526 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 589.1797152.6250
Module start 'layout' 0.00520.0036 741.804739.4453
Module start 'content' 0.00871.1425 781.2500489.3438
Module end 'content' 1.15120.0013 1,270.59388.1563
Script end 1.1525  1,278.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2601160.0002
Check MTime0.00130.1111160.0001
Mysql Total
Database connection0.00070.061910.0007
Mysqli_queries1.115396.7672540.0207
Looping result0.00040.0379520.0000
Template Total1.123397.520.5617
Template load0.00180.154820.0009
Template processing1.121597.306820.5608
Template load and register function0.00010.009810.0001
states
state_id_array0.00150.131210.0015
state_identifier_array0.00110.095820.0006
Override
Cache load0.00140.1245170.0001
Sytem overhead
Fetch class attribute can translate value0.00080.069820.0004
Fetch class attribute name0.00080.068420.0004
XML
Image XML parsing0.00020.020720.0001
class_abstraction
Instantiating content class attribute0.00000.000520.0000
General
dbfile0.00110.0940100.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs