php - remove an Image programmatically in ezpublish -


i have object in ezpublish has image attribute. attribute has image value want remove programmatically in php. ( image value , not attribute )

any idea how ?

for versions of ez publish (legacy) prior oct 15, 2013, or git tag, 'v2014.03.1' including ez publish 4.7 'deletestoredobjectattribute' method -requires- non-null second argument value passed in versions of ez publish legacy before following commit:

see: https://github.com/ezsystems/ezpublish-legacy/commit/61aaa002c00ccfb86b3e02856b319f54b3405ef8

this includes ez publish 4.7 , question author's specific use case. why answer more accurate others.

without second non-null parameter, aliases image files deleted filesystem ... image aliases information (alias references, meta data, etc) still exist content object attribute content (database storage xml).

without second non-parameter image appear still partially existing in content object image preview, (ie: usage of image path, meta data system) display broken image , represent corrupt / incomplete copy of original content object attribute content.

for maximum backwards compatibility, it's best pass non-null second parameter since versions of ez publish legacy beyond 10/15/2013 not use second parameter in way.

the following complete example of source code required remove content object image attribute content (and remove related meta-data , image file disk) best way possible version of ez publish legacy.

// following 2 variables filled dummy values. // need change contents of these variables match // actual use case identifiers (content object id / class attribute identifier) $objectid = 42; $objectimageattributeidentifier = 'profile_image';  $object = ezcontentobject::fetch( $objectid );  $objectid = $object->attribute( 'id' ); $objectcurrentversion = $object->attribute( 'current_version' ); $objectdatamap = $object->attribute( 'data_map' );  if ( isset( $objectdatamap[ $objectimageattributeidentifier ] ) ) {     $objectimageattribute = $objectdatamap[ $objectimageattributeidentifier ];      if ( $objectimageattribute->attribute( 'has_content' ) )     {         $objectimagedatatype = $objectimageattribute->datatype();         $objectimagedatatype->deletestoredobjectattribute( $objectimageattribute, $objectcurrentversion );          ezcontentcachemanager::clearcontentcacheifneeded( $objectid );     } } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -