Add new Section Media Element

@param string $src
@param string $type

@return mixed
333595
public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) {
		$mediaId = md5($src);
		$key = ($type == 'image') ? 'images' : 'embeddings';
		
		if(!array_key_exists($mediaId, self::$_sectionMedia[$key])) {
			$cImg = self::countSectionMediaElements('images');
			$cObj = self::countSectionMediaElements('embeddings');
			$rID = self::countSectionMediaElements() + 7;
			
			$media = array();
			
			if($type == 'image') {
				$cImg++;
				$inf = pathinfo($src);
				$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
				
				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';
					}
				}
				
				$folder = 'media';
				$file = $type.$cImg.'.'.strtolower($ext);
			} elseif($type == 'oleObject') {
				$cObj++;
				$folder = 'embedding';
				$file = $type.$cObj.'.bin';
			}
			
			$media['source'] = $src;
			$media['target'] = "$folder/section_$file";
			$media['type'] = $type;
			$media['rID'] = $rID;
			
			self::$_sectionMedia[$key][$mediaId] = $media;
			
			if($type == 'oleObject') {
				return array($rID, ++self::$_objectId);
			} else {
				return $rID;
			}
		} else {
			if($type == 'oleObject') {
				$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
				return array($rID, ++self::$_objectId);
			} else {
				return self::$_sectionMedia[$key][$mediaId]['rID'];
			}
		}
	}
363794
public function create($type)
    {
        switch ($type) {
            case self::AUDIO:
                return new Type\Audio();
            case self::IMAGE:
                return new Type\Image();
            case self::GENERAL:
                return new Type\General();
            case self::VIDEO:
                return new Type\Video();
            case self::SUBTITLE:
                return new Type\Subtitle();
            case self::MENU:
                return new Type\Menu();
            case self::OTHER:
                return new Type\Other();
            default:
                throw new UnknownTrackTypeException($type);
        }
    }
514561
public function addStorageType($type)
    {
        parent::addStorageType($type);

        if (!is_string($type)) {
            return $this;
        }

        foreach ($this->getMessageCollection()->getItems() as $item) {
            $this->storageMessages[$type][] = $item;
        }

        $this->getMessageCollection()->clear();
        return $this;
    }
1156390
public function addIFrame($src, $windowWidth, $windowHeight, $thumb="", $title = "", $caption="", $width="", $height="")
	{
		$this->addXmlnukeObject(XmlnukeMediaItem::IFrameFactory($src, $windowWidth, $windowHeight, $thumb, $title, $caption, $width, $height));
	}
876246
public function addGuide($type, $href){
		if( !$this->dom->guide->count() ){
			$guide = $this->dom->addChild('guide');
		}else{
			$guide = $this->dom->guide;
		}
		$ref = $guide->addChild('reference');
		$ref['type'] = $type;
		$ref['href'] = $href;
		return $ref;
	}
958708
public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) {
		$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont, $styleParagraph);
		$rID = PHPWord_Media::addSectionLinkElement($linkSrc);
		$link->setRelationId($rID);
		
		$this->_elementCollection[] = $link;
		return $link;
	}
1323210
public function append($filename,$content,$type=''){
        if(is_file($filename)){
            $content =  $this->read($filename,$type).$content;
        }
        return $this->put($filename,$content,$type);
    }
357043
public function create_simple_html_dom( $src ){
		// Simple HTML DOM
		$simple_html_dom = str_get_html(
			$src ,
			true, // $lowercase
			true, // $forceTagsClosed
			DEFAULT_TARGET_CHARSET, // $target_charset
			false, // $stripRN
			DEFAULT_BR_TEXT, // $defaultBRText
			DEFAULT_SPAN_TEXT // $defaultSpanText
		);
		return $simple_html_dom;
	}
1039495
public function appendAlternate($href, $type, $title, $media = null, $conditional = '')
    {
        return $this->_setAlternate($href, $type, $title, $media, true, $conditional);
    }
978229
final protected function createSourceElement($type, $src)
    {
        // Tag attributes
        $attrs = array(
            'src' => $src,
            'type' => $type
        );

        $node = new NodeElement();

        return $node->openTag('source')
                    ->addAttributes($attrs)
                    ->finalize(true);
    }
1065189
public function setMedia($src)
    {
        $src = str_replace(
            [
                'youtube.com/',
                'youtu.be',
                '?rel=0',
            ],
            [
                'youtube.com/embed/',
                'youtube.com/embed/',
                '',
            ],
            $src
        );

        if (strpos($src, 'youtube') !== false) {
            $src .= '?rel=0';
        }

        $this->media->attributes->addAttribute('src', $src);

        return $this;
    }
438405
private void addResultSection(String mediaQueryPath, Section section) {
        Section qry = mediaQueries.get(mediaQueryPath);
        if (qry == null) {
            qry = new Section();
            qry.getSelectors().add(Collections.singletonList(mediaQueryPath));
            mediaQueries.put(mediaQueryPath, qry);
        }
        qry.addSubSection(section);
    }
522910
public function addElement($element_name, $type, $contents, $attr_collections, $attributes = array())
    {
        $module = $this->getAnonymousModule();
        // assume that if the user is calling this, the element
        // is safe. This may not be a good idea
        $element = $module->addElement($element_name, $type, $contents, $attr_collections, $attributes);
        return $element;
    }
210442
public function embed(string $src){
        if(strtolower(substr($src, 0, 14)) !== "<!doctype html"){
            return $src;
        }

        $src        = $this->getDomDocument($src);
        $debug      = $this->getDomDocument($this->generateDebugHtml());
        $srcPath    = new \DOMXPath($src);
        $debugPath  = new \DOMXPath($debug);

        $headNode   = $srcPath->query("//head")->item(0);
        $bodyNode   = $srcPath->query("//body")->item(0);

        if($headNode !== null && $bodyNode !== null){
            $headNode->appendChild($src->importNode($debugPath->query("//head/style")->item(0), true));
            $bodyNode->appendChild($src->importNode($debugPath->query("//body/div")->item(0), true));
            $bodyNode->appendChild($src->importNode($debugPath->query("//body/script")->item(0), true));
        }

        return $src->saveHTML();
    }
604581
public function addMaterial($mediaPath, $type, $data = [])
    {
        $result = $this->httpPost(self::WECHAT_MATERIAL_ADD_PREFIX, array_merge($data, [
            'media' => $this->uploadFile($mediaPath)
        ]), [
            'access_token' => $this->getAccessToken(),
            'type' => $type
        ]);
        return isset($result['media_id']) ? $result : false;
    }
604006
public static function createFromMultilingualSection(Section $section)
    {
        $parent = \Page::getByPath(STACKS_PAGE_PATH);
        $data = array();
        $data['name'] = $section->getLocale();
        $data['cHandle'] = $section->getLocale();
        $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
        $page = $parent->add($type, $data);

        $sc = new self($page);

        return $sc;
    }
880597
public function add($handle, $type, $args = array())
	{
		list($src, $deps, $ver, $last) = $args;

		$data = array();
		if ($src)
			$data['src'] = $src;

		if ($deps)
			$data['deps'] = $deps;

		if ($ver)
			$data['ver'] = $ver;

		if ($last)
			$data[('script' == $type ? 'in_footer' : 'media')] = $last;

		$this->assets[$type][$handle] = $data;

		return true;
	}