Forums / Install & configuration / Image file cleanup

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Image file cleanup

Author Message

Sebastiaan van der Vliet

Tuesday 02 June 2009 5:48:44 am

Hi,

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?

Thanks,
Sebastiaan

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Sebastiaan van der Vliet

Tuesday 02 June 2009 7:59:42 am

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();
			$db->begin();
			$version->removeThis();
			$cli->output("removing version ".$versionID);
			$db->commit();
		}
	}
	$objectVersions = $eZObject->versions();
	$cli->output(count($objectVersions)." versions remaining. Current version is ".$objectVersionID);
}

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Heath

Tuesday 02 June 2009 9:02:03 am

Sebastiaan,

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

Cheers,
Heath

7x | https://se7enx.com/
Brookins Consulting | https://brookinsconsulting.com/
Certified | http://web.archive.org/web/201012...th.ez.no/certification/verify/380350
Solutions | https://projects.exponential.earth/users/community/brookins-consulting
eZpedia community documentation project | http://ezpedia.se7enx.com