lib/PHPWord/PHPWord/Media.php
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
		$mediaId = md5($src);
		$key = 'header'.$headerCount;
		
		if(!array_key_exists($key, self::$_headerMedia)) {
			self::$_headerMedia[$key] = array();
		}
		
		if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
			$cImg = self::countHeaderMediaElements($key);
			$rID = $cImg + 1;
			
			$cImg++;
			$inf = pathinfo($src);
			$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
			
			$media = array();
			if($isMemImage) {
				$ext = $memoryImage->getImageExtension();
				$media['isMemImage'] = true;
				$media['createfunction'] = $memoryImage->getImageCreateFunction();
				$media['imagefunction'] = $memoryImage->getImageFunction();
			} else {
				$ext = $inf['extension'];
				if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
					$ext = 'jpg';
				}
			}
			$file = 'image'.$cImg.'.'.strtolower($ext);
			
			$media['source'] = $src;
			$media['target'] = 'media/'.$key.'_'.$file;
			$media['type'] = 'image';
			$media['rID'] = $rID;
			
			self::$_headerMedia[$key][$mediaId] = $media;
			
			return $rID;
		} else {
			return self::$_headerMedia[$key][$mediaId]['rID'];
		}
	}
public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
		$mediaId = md5($src);
		$key = 'header'.$headerCount;
		
		if(!array_key_exists($key, self::$_headerMedia)) {
			self::$_headerMedia[$key] = array();
		}
		
		if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
			$cImg = self::countHeaderMediaElements($key);
			$rID = $cImg + 1;
			
			$cImg++;
			$inf = pathinfo($src);
			$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
			
			$media = array();
			if($isMemImage) {
				$ext = $memoryImage->getImageExtension();
				$media['isMemImage'] = true;
				$media['createfunction'] = $memoryImage->getImageCreateFunction();
				$media['imagefunction'] = $memoryImage->getImageFunction();
			} else {
				$ext = $inf['extension'];
				if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
					$ext = 'jpg';
				}
			}
			$file = 'image'.$cImg.'.'.strtolower($ext);
			
			$media['source'] = $src;
			$media['target'] = 'media/'.$key.'_'.$file;
			$media['type'] = 'image';
			$media['rID'] = $rID;
			
			self::$_headerMedia[$key][$mediaId] = $media;
			
			return $rID;
		} else {
			return self::$_headerMedia[$key][$mediaId]['rID'];
		}
	}
public static function addHeaderMediaElement ( $ headerCount , $ src , PHPWord_Section_MemoryImage $ memoryImage = null ) { $ mediaId = md5 ( $ src ) ; $ key = 'header' . $ headerCount ; if ( ! array_key_exists ( $ key , self :: $ _headerMedia ) ) { self :: $ _headerMedia [ $ key ] = array ( ) ; } if ( ! array_key_exists ( $ mediaId , self :: $ _headerMedia [ $ key ] ) ) { $ cImg = self :: countHeaderMediaElements ( $ key ) ; $ rID = $ cImg + 1 ; $ cImg ++ ; $ inf = pathinfo ( $ src ) ; $ isMemImage = ( substr ( strtolower ( $ inf [ 'extension' ] ) , 0 , 3 ) == 'php' ) ? true : false ; $ media = array ( ) ; if ( $ isMemImage ) { $ ext = $ memoryImage -> getImageExtension ( ) ; $ media [ 'isMemImage' ] = true ; $ media [ 'createfunction' ] = $ memoryImage -> getImageCreateFunction ( ) ; $ media [ 'imagefunction' ] = $ memoryImage -> getImageFunction ( ) ; } else { $ ext = $ inf [ 'extension' ] ; if ( $ ext == 'jpeg' ) { // Office crashes when adding a jpEg Image, so rename to jpg
 $ ext = 'jpg' ; } } $ file = 'image' . $ cImg . '.' . strtolower ( $ ext ) ; $ media [ 'source' ] = $ src ; $ media [ 'target' ] = 'media/' . $ key . '_' . $ file ; $ media [ 'type' ] = 'image' ; $ media [ 'rID' ] = $ rID ; self :: $ _headerMedia [ $ key ] [ $ mediaId ] = $ media ; return $ rID ; } else { return self :: $ _headerMedia [ $ key ] [ $ mediaId ] [ 'rID' ] ; } }
Add new Header Media Element

@param int $headerCount
@param string $src
@return int
Add new Header Media Element