eZ Community » Forums » Install & configuration » Image file cleanup

Image file cleanup

Image file cleanup

Tuesday 02 June 2009 2:48:44 pm - 2 replies


It appears that the bin/php/flatten.php script to remove non-published versions of the object does not clean up the matching image files per removed object version. Is this a correct assumption, and if so, what function/script would be the best option to use to clean up the image files?


Tuesday 02 June 2009 4:59:42 pm

Hmm-what about this...

function deleteOldVersions( $eZObjectID )
	 global $cli;
	$eZObject = eZContentObject::fetch( $eZObjectID );
	$objectVersions = $eZObject->versions();
	$objectVersionID = $eZObject->attribute( 'current_version' );
	$cli->output(count($objectVersions)." versions");
	foreach ( $objectVersions as $version )
		$versionID = $version->attribute('version');
		if ($objectVersionID != $versionID)
			$contentObjectAttributes = $version->contentObjectAttributes();
			foreach ( $contentObjectAttributes as $contentObjectAttribute )
				$classAttribute = $contentObjectAttribute->contentClassAttribute();
				$dataTypeString = $classAttribute->attribute( 'data_type_string' );

				if ($dataTypeString == "ezimage")
					 eZImageAliasHandler::removeAllAliases( $contentObjectAttribute );
	 				$cli->output("deleting image");
			$db = eZDB::instance();
			$cli->output("removing version ".$versionID);
	$objectVersions = $eZObject->versions();
	$cli->output(count($objectVersions)." versions remaining. Current version is ".$objectVersionID);

Tuesday 02 June 2009 6:02:03 pm


I would recommend creating a new issue in the issue tracker to add this functionality into the default ezpublish releases. This seems like something that should be available by default.



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

36 542 Users on board!

Forums menu

Proudly Developed with from