Forums / Developer / Trouble with ezimagealiashandler

Trouble with ezimagealiashandler

Author Message

Gabriel Ambuehl

Sunday 02 October 2005 8:26:15 am

I'm trying to get the URL of some image, but whatever I try with ezimagealiashandler, I get errors:

$aliashandler= new eZImageAliasHandler($targetcontentobjectattribute);
eZDebug::writeNotice($aliashandler);
$list=$aliashandler->aliasList();

Shows an aliashandler that is initialized:

class ezimagealiashandler {
  var $ContentObjectAttribute = 'class ezcontentobjectattribute {
  var $HTTPValue = NULL;
  var $Content = NULL;
  var $DisplayInfo = NULL;
  var $IsValid = NULL;
  var $ContentClassAttributeID = \'118\';
  var $ValidationError = NULL;
  var $ValidationLog = NULL;
  var $ContentClassAttributeIdentifier = \'image\';
  var $ContentClassAttributeCanTranslate = NULL;
  var $ContentClassAttributeName = NULL;
  var $ContentClassAttributeIsInformationCollector = NULL;
  var $ContentClassAttributeIsRequired = NULL;
  var $PersistentDataDirty = false;
  var $InputParameters = false;
  var $HasValidationError = false;
  var $DataTypeCustom = NULL;
  var $ID = \'267\';
  var $ContentObjectID = \'75\';
  var $Version = \'2\';
  var $LanguageCode = \'eng-GB\';
  var $AttributeOriginalID = \'0\';
  var $SortKeyInt = \'0\';
  var $SortKeyString = \'\';
  var $DataTypeString = \'ezimage\';
  var $DataText = \'<?xml version="1.0" encoding="UTF-8"?>
<ezimage serial_number="1" is_valid="1" filename="purple_something.jpg" suffix="jpg" basename="purple_something" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something.jpg" original_filename="packages/addons/gallery/simplefiles/9a1b2360.jpg" mime_type="image/jpeg" width="400" height="300" alternative_text="Purple haze" alias_key="1293033771" timestamp="1127643196">
  <original attribute_id="267" attribute_version="1" attribute_language="eng-GB"/>
  <alias name="reference" filename="purple_something_reference.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_reference.jpg" mime_type="image/jpeg" width="400" height="300" alias_key="-1689502181" timestamp="1128261017" is_valid="1"/>
  <alias name="medium" filename="purple_something_medium.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_medium.jpg" mime_type="image/jpeg" width="200" height="150" alias_key="1524669830" timestamp="1128262523" is_valid="1"/>
<alias name="large" filename="purple_something_large.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_large.jpg" mime_type="image/jpeg" width="300" height="225" alias_key="860096096" timestamp="1128262546" is_valid="1"/><alias name="small" filename="purple_something_small.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_small.jpg" mime_type="image/jpeg" width="100" height="75" alias_key="154637809" timestamp="1128262563" is_valid="1"/></ezimage>
\';
  var $DataInt = NULL;
  var $DataFloat = \'0\';
}';
}

But then proceeds with:


Fatal error: Call to a member function on a non-object in /home/buz/www/ezpublish-3.7.0rc2/kernel/classes/datatypes/ezimage/ezimagealiashandler.php on line 459
Fatal error: eZ publish did not finish its request

Is this a bug or am I doing something wrong?

Visit http://triligon.org

Xavier Dutoit

Monday 03 October 2005 1:11:43 am

Hi,

If your purple.jpeg is taken from a camera, the guilty might be crap data on EXIF. ez stores the EXIF data on xml. It tooks me an howfull lot of time to find this one ;)

I've modified the ezimage libs so they don't store any information about EXIF, that is never used anyway if I'm right (there is a bug report about that filled by someone else).

http://www.sydesy.com

Gabriel Ambuehl

Monday 03 October 2005 1:17:54 am

It is actually one of the pics that comes with the EZP galleries ;)

Visit http://triligon.org

Ɓukasz Serwatka

Monday 03 October 2005 2:22:50 am

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

Gabriel Ambuehl

Monday 03 October 2005 3:18:19 am

Thanks I'll try that.

Visit http://triligon.org

Gabriel Ambuehl

Monday 03 October 2005 6:10:51 am

This seems to work (for the most part) but some weird things happen :

1) I can't doeZDebug::writeNotice($imageattribute->content()), that gives (that is probably because some circular reference I'd say):

class ezimagealiashandler { var $ContentObjectAttribute = class ezcontentobjectattribute { var $HTTPValue = NULL; var $Content = class ezimagealiashandler { var $ContentObjectAttribute = class ezcontentobjectattribute { var $HTTPValue = NULL; var $Content = class ezimagealiashandler { var $ContentObjectAttribute = class ezcontentobjectattribute { var $HTTPValue = NULL; var $Content = class ezimagealiashandler { var $ContentObjectAttribute = class ezcontentobjectattribute {
Fatal error: Nesting level too deep - recursive dependency? in /home/buz/www/ezpublish-3.7.0rc2/lib/ezutils/classes/ezdebug.php on line 569
Fatal error: eZ publish did not finish its request

2) Not all available aliases are being shown, it seems:

class ezcontentobjectattribute {
  var $HTTPValue = NULL;
  var $Content = NULL;
  var $DisplayInfo = NULL;
  var $IsValid = NULL;
  var $ContentClassAttributeID = '118';
  var $ValidationError = NULL;
  var $ValidationLog = NULL;
  var $ContentClassAttributeIdentifier = 'image';
  var $ContentClassAttributeCanTranslate = NULL;
  var $ContentClassAttributeName = NULL;
  var $ContentClassAttributeIsInformationCollector = NULL;
  var $ContentClassAttributeIsRequired = NULL;
  var $PersistentDataDirty = false;
  var $InputParameters = false;
  var $HasValidationError = false;
  var $DataTypeCustom = NULL;
  var $ID = '267';
  var $ContentObjectID = '75';
  var $Version = '2';
  var $LanguageCode = 'eng-GB';
  var $AttributeOriginalID = '0';
  var $SortKeyInt = '0';
  var $SortKeyString = '';
  var $DataTypeString = 'ezimage';
  var $DataText = '<?xml version="1.0" encoding="UTF-8"?>
<ezimage serial_number="1" is_valid="1" filename="purple_something.jpg" suffix="jpg" basename="purple_something" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something.jpg" original_filename="packages/addons/gallery/simplefiles/9a1b2360.jpg" mime_type="image/jpeg" width="400" height="300" alternative_text="Purple haze" alias_key="1293033771" timestamp="1127643196">
  <original attribute_id="267" attribute_version="1" attribute_language="eng-GB"/>
  <alias name="reference" filename="purple_something_reference.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_reference.jpg" mime_type="image/jpeg" width="400" height="300" alias_key="-1689502181" timestamp="1128261017" is_valid="1"/>
  <alias name="medium" filename="purple_something_medium.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_medium.jpg" mime_type="image/jpeg" width="200" height="150" alias_key="1524669830" timestamp="1128262523" is_valid="1"/>
<alias name="large" filename="purple_something_large.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_large.jpg" mime_type="image/jpeg" width="300" height="225" alias_key="860096096" timestamp="1128262546" is_valid="1"/><alias name="small" filename="purple_something_small.jpg" suffix="jpg" dirpath="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB" url="var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_small.jpg" mime_type="image/jpeg" width="100" height="75" alias_key="154637809" timestamp="1128335588" is_valid="1"/></ezimage>
';
  var $DataInt = NULL;
  var $DataFloat = '0';
}

Notice: 	Oct 03 2005 15:07:44

array (
  'original' => 
  array (
    'name' => 'original',
    'width' => '400',
    'height' => '300',
    'mime_type' => 'image/jpeg',
    'filename' => 'purple_something.jpg',
    'suffix' => 'jpg',
    'dirpath' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB',
    'basename' => 'purple_something',
    'alternative_text' => 'Purple haze',
    'text' => 'Purple haze',
    'original_filename' => 'packages/addons/gallery/simplefiles/9a1b2360.jpg',
    'url' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something.jpg',
    'alias_key' => '1293033771',
    'timestamp' => '1127643196',
    'full_path' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something.jpg',
    'is_valid' => '1',
    'is_new' => false,
    'filesize' => 24718,
    'info' => false,
  ),
  'small' => 
  array (
    'name' => 'small',
    'width' => '100',
    'height' => '75',
    'mime_type' => 'image/jpeg',
    'filename' => 'purple_something_small.jpg',
    'suffix' => 'jpg',
    'dirpath' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB',
    'alias_key' => '154637809',
    'timestamp' => '1128335588',
    'is_valid' => '1',
    'url' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_small.jpg',
    'basename' => 'purple_something',
    'alternative_text' => 'Purple haze',
    'text' => 'Purple haze',
    'original_filename' => 'packages/addons/gallery/simplefiles/9a1b2360.jpg',
    'full_path' => 'var/plain/storage/images/galleries/misc_flowers/purple_something/267-2-eng-GB/purple_something_small.jpg',
    'is_new' => false,
    'info' => false,
    'filesize' => 9539,
  ),
)

This is more worrisome. While there are three aliases defined, I only get to see one plus the original one?

Visit http://triligon.org