Forums / Developer / Syntax API for get original url of an image

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.

eZ debug

Timing: Jan 31 2025 00:16:09
Script start
Timing: Jan 31 2025 00:16:09
Module start 'content'
Timing: Jan 31 2025 00:16:09
Module end 'content'
Timing: Jan 31 2025 00:16:09
Script end

Main resources:

Total runtime0.1845 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 588.0703370.2734
Module start 'content' 0.00810.0144 958.34381,005.5781
Module end 'content' 0.02250.1619 1,963.92193,894.7891
Script end 0.1844  5,858.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00462.4691200.0002
Check MTime0.00140.7530200.0001
Mysql Total
Database connection0.00100.560510.0010
Mysqli_queries0.087147.24051410.0006
Looping result0.00120.63851390.0000
Template Total0.161687.610.1616
Template load0.00100.520510.0010
Template processing0.160687.051710.1606
Override
Cache load0.00060.346410.0006
Sytem overhead
Fetch class attribute can translate value0.00170.945410.0017
XML
Image XML parsing0.00040.234210.0004
General
dbfile0.00713.8305200.0004
String conversion0.00000.003430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs