protected function buildManifestAssetsHtml() {

		$html = '';
		$path_to_assets = $this->tmpDir . '/OEBPS/assets';
		$assets = scandir( $path_to_assets );
		$used_ids = [];

		foreach ( $assets as $asset ) {
			if ( '.' === $asset || '..' === $asset ) {
				continue;
			}
			$mimetype = $this->mediaType( "$path_to_assets/$asset" );
			if ( $this->coverImage === $asset ) {
				$file_id = 'cover-image';
			} else {
				$file_id = 'media-' . pathinfo( "$path_to_assets/$asset", PATHINFO_FILENAME );
				$file_id = Sanitize\sanitize_xml_id( $file_id );
			}

			// Check if a media id has already been used, if so give it a new one
			$check_if_used = $file_id;
			for ( $i = 2; $i <= 999; $i++ ) {
				if ( empty( $used_ids[ $check_if_used ] ) ) {
					break;
				} else {
					$check_if_used = $file_id . "-$i";
				}
			}
			$file_id = $check_if_used;

			$html .= sprintf( '<item id="%s" href="OEBPS/assets/%s" media-type="%s" />', $file_id, $asset, $mimetype ) . "\n";

			$used_ids[ $file_id ] = true;
		}

		return $html;
	}
protected function buildManifestAssetsHtml() {

		$html = '';
		$path_to_assets = $this->tmpDir . '/OEBPS/assets';
		$assets = scandir( $path_to_assets );
		$used_ids = [];

		foreach ( $assets as $asset ) {
			if ( '.' === $asset || '..' === $asset ) {
				continue;
			}
			$mimetype = $this->mediaType( "$path_to_assets/$asset" );
			if ( $this->coverImage === $asset ) {
				$file_id = 'cover-image';
			} else {
				$file_id = 'media-' . pathinfo( "$path_to_assets/$asset", PATHINFO_FILENAME );
				$file_id = Sanitize\sanitize_xml_id( $file_id );
			}

			// Check if a media id has already been used, if so give it a new one
			$check_if_used = $file_id;
			for ( $i = 2; $i <= 999; $i++ ) {
				if ( empty( $used_ids[ $check_if_used ] ) ) {
					break;
				} else {
					$check_if_used = $file_id . "-$i";
				}
			}
			$file_id = $check_if_used;

			$html .= sprintf( '<item id="%s" href="OEBPS/assets/%s" media-type="%s" />', $file_id, $asset, $mimetype ) . "\n";

			$used_ids[ $file_id ] = true;
		}

		return $html;
	}
protected function buildManifestAssetsHtml ( ) { $ html = '' ; $ path_to_assets = $ this -> tmpDir . '/OEBPS/assets' ; $ assets = scandir ( $ path_to_assets ) ; $ used_ids = [ ] ; foreach ( $ assets as $ asset ) { if ( '.' === $ asset || '..' === $ asset ) { continue ; } $ mimetype = $ this -> mediaType ( "$path_to_assets/$asset" ) ; if ( $ this -> coverImage === $ asset ) { $ file_id = 'cover-image' ; } else { $ file_id = 'media-' . pathinfo ( "$path_to_assets/$asset" , PATHINFO_FILENAME ) ; $ file_id = Sanitize \ sanitize_xml_id ( $ file_id ) ; } // Check if a media id has already been used, if so give it a new one $ check_if_used = $ file_id ; for ( $ i = 2 ; $ i <= 999 ; $ i ++ ) { if ( empty ( $ used_ids [ $ check_if_used ] ) ) { break ; } else { $ check_if_used = $ file_id . "-$i" ; } } $ file_id = $ check_if_used ; $ html .= sprintf ( '<item id="%s" href="OEBPS/assets/%s" media-type="%s" />' , $ file_id , $ asset , $ mimetype ) . "\n" ; $ used_ids [ $ file_id ] = true ; } return $ html ; }
Find all the image files, insert them into the OPF file

@return string
Find all the image files insert them into the OPF file