Syntax API for get original url of an image

Author Message

Christophe Saint-Pierre

Sunday 30 November 2008 6:59:32 am

Hi ,
I would like to get the url to the original filename of a Node of the basic class Image.
When i use attribute|show I can see :
url string 'var/fre/storage/images/media/images/fre/doctorat/maison/61298-1-fre-FR/Maison.jpg'

But in the php , after the basic :
$node = eZContentObjectTreeNode::fetch( $nodeId );
$Object = $node->attribute( 'object' );
$object_id = $Object->attribute( 'id' );
$url_alias= $node->attribute( 'url_alias' );

I don't know how to get the url of the original image (var/fre/storage/images/media/images/fre/doctorat/maison/61298-1-fre-FR/Maison.jpg)

Somebody knows ?

Thanks

Arnaud Lafon

Monday 01 December 2008 2:35:34 am

Hi Christophe,

Assuming $node is an "ezcontentobjecttreenode" php object :

$dataMap = $node->dataMap(); // or ->attribute( 'data_map' ); will return an array of ezcontentobjectattribute php object

each ezcontentobjectattribute has a "content" and this "content" is controlled by a datatype and its objectAttributeContent() method. So If you do :

$myImageAttribute = $dataMap['image_attribute']; // the attribute identifier is "image_attribute"
$myImageContent = $myImageAttribute->content(); // you'll get $myImageContent as an eZImageAliasHandler

this object is defined in kernel/classes/datatypes/ezimage/ezimagealiashandler.php

by using $myImageContent->attribute( 'something' ) you'll be able to access ImageVariation and in each image variation you'll have an attribute called "full_path" which is actually the same ez uses in its template to build the <img src=""/> tags.

Hope this helps.

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Heath

Monday 01 December 2008 9:42:59 am

Take a look at these interesting articles on the subject.

http://74.125.95.132/search?q=cache:UBZrvOFxI6UJ:ezpedia.org/wiki/ez/solution_fetching_ezimage_datatype_image_alias_properties_using_php+ezImage+site:ezpedia.org&hl=en&ct=clnk&cd=1&gl=us

http://74.125.95.132/search?q=cache:lWM2xQ45PjUJ:ezpedia.org/wiki/en/ez/ezimagealiashandler+ezImage+site:ezpedia.org&hl=en&ct=clnk&cd=3&gl=us

hth,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Christophe Saint-Pierre

Thursday 04 December 2008 9:14:50 am

Thanks a lot , both of you.

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 18 2025 16:13:27
Script start
Timing: Jan 18 2025 16:13:27
Module start 'layout'
Timing: Jan 18 2025 16:13:27
Module start 'content'
Timing: Jan 18 2025 16:13:28
Module end 'content'
Timing: Jan 18 2025 16:13:28
Script end

Main resources:

Total runtime1.2410 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.0469152.6406
Module start 'layout' 0.00570.0033 740.687539.4766
Module start 'content' 0.00901.2303 780.1641591.7500
Module end 'content' 1.23930.0017 1,371.914112.1250
Script end 1.2410  1,384.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2844160.0002
Check MTime0.00140.1120160.0001
Mysql Total
Database connection0.00090.069210.0009
Mysqli_queries1.177894.9097620.0190
Looping result0.00070.0569600.0000
Template Total1.204397.020.6021
Template load0.00210.168820.0010
Template processing1.202296.870520.6011
Template load and register function0.00020.013610.0002
states
state_id_array0.00130.105110.0013
state_identifier_array0.00260.210920.0013
Override
Cache load0.00180.1477350.0001
Sytem overhead
Fetch class attribute can translate value0.00110.087330.0004
Fetch class attribute name0.00200.162960.0003
XML
Image XML parsing0.00120.097930.0004
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00090.0722240.0000
String conversion0.00000.000640.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs