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.