Share » Forums » Developer » Get the image storage path from a...

Get the image storage path from a ContentObjectID (php-side)

Get the image storage path from a ContentObjectID (php-side)

Monday 30 January 2006 6:48:47 am - 4 replies

Modified on Monday 30 January 2006 6:58:47 am by Alexandre Nion

Author Message

Łukasz Serwatka

Monday 30 January 2006 6:57:59 am

Hi Alexandre,

Use this code to get image URL

objectWithIMG = eZContentObject::fetch( 171 ); 
 
$dataMap =& $objectWithIMG->attribute( 'data_map' ); 
 
$image =& $dataMap['image']->content(); 
 
$list =& $image->aliasList(); 
 
var_dump( $list['original']['url'] );

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Alexandre Nion

Monday 30 January 2006 8:26:21 am

wow thank you Lukasz, this code rocks!
Exactly what I needed, I knew it wasn't so hard in the end ;)

Piotrek Karaś

Wednesday 11 February 2009 10:04:47 pm

Hi guys,

And how do we generate an alias that has not been generated up to the moment of fetching?

For example: I have 20 aliases defined in the website, but the aliasList() method only returns 4 (the underlying XML-base for that method also contains 4 alias entries). How do I force particular alias generation in PHP?

Thanks!

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Piotrek Karaś

Thursday 12 February 2009 12:08:31 am

OK, for those interested and also for verification, this seems to work:

<?php
$targetAliasName = 'my_huge_image';
$contentObjectAttributeID = 1234567...;
$contentObjectAttribute = eZContentObjectAttribute::fetch( $contentObjectAttributeID );
$aliasHandler = new eZImageAliasHandler( $contentObjectAttribute );
$myHugeImageAliasData = $aliasHandler->imageAlias( $targetAliasName );
?>

If the alias entry had not existed, seems to be created automatically (provided it had existed in the image.ini declarations). I hope this includes the internal caching layer ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu