Monday 30 January 2006 3:48:47 pm - 4 replies
Hi all,
I'm in a php function and I have the ID of a contentObject which represents an ezImage object. And my problem is that I'd like to know his real storage url but I don't see any simple way to do it, although it shouldn't be so difficult... I mean that when I do:
$myImageObject = eZContentObject :: fetch( 76 ); // where 76 is my contentObjectID
print_r( $myImageObject );
// displays properties but doesn't display any contained attributes.. don't know why..
// Then I can do:
print_r( $myImageObject->contentObjectAttributes() );
// to display all the object attributes..
Array {
....
[2] => ezcontentobjectattribute Object
(
...
[ID] => 266
[ContentObjectID] => 76
[Version] => 2
[LanguageCode] => fre-FR
[AttributeOriginalID] => 0
[SortKeyInt] => 0
[SortKeyString] =>
[DataTypeString] => ezimage
[DataText] => <?xml version="1.0" encoding="UTF-8"?>
<ezimage serial_number="1"
is_valid="1"
filename="geek.png"
suffix="png"
basename="geek"
dirpath="var/plain/storage/images/media/images/geek/266-2-fre-FR"
url="var/plain/storage/images/media/images/geek/266-2-fre-FR/geek.png"
original_filename="alignement_resultats.png"
mime_type="image/png"
width="1155"
height="217"
alternative_text=""
alias_key="1293033771"
timestamp="1138213887">
<original attribute_id=""
attribute_version=""
attribute_language="" />
</ezimage>
[DataInt] =>
[DataFloat] => 0
)
...
}
// Well, now I can see the storage path in the DataText field but I don't know how to access it easily (without having to parse individually, I'd like a generic method..):
So is there a way to get the image storage url easily? (maybe via ezImage or imageHanler, I didn't manage with the objects tried)
Thanx for your lights,
Alexandre
Modified on Monday 30 January 2006 3:58:47 pm by Alexandre Nion
Monday 30 January 2006 3:57:59 pm
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'] );
Modified on Monday 30 January 2006 4:07:44 pm by Łukasz Serwatka
Thursday 12 February 2009 7:04:47 am
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!
Thursday 12 February 2009 9: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 ![]()
Modified on Thursday 12 February 2009 9:09:57 am by Piotrek Karaś
You must be logged in to post messages in this topic!