当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageHandler::DownloadImage方法代码示例

本文整理汇总了PHP中ImageHandler::DownloadImage方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHandler::DownloadImage方法的具体用法?PHP ImageHandler::DownloadImage怎么用?PHP ImageHandler::DownloadImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageHandler的用法示例。


在下文中一共展示了ImageHandler::DownloadImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addImageFromUrl

 /**
  * Add an image to the file.
  *
  * @param string $url Url to the image
  *
  * @return int The reference of the image, false if the image couldn't be downloaded
  */
 public function addImageFromUrl($url)
 {
     $image = ImageHandler::DownloadImage($url);
     if ($image === false) {
         return false;
     }
     return $this->addImage($image);
 }
开发者ID:wallabag,项目名称:php-mobi,代码行数:15,代码来源:MultipleFileHandler.php

示例2: handleImages

 /**
  *
  * @param DOMElement $dom
  * @return array
  */
 private function handleImages($dom, $url)
 {
     $images = array();
     $parts = parse_url($url);
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         $parsed = parse_url($src);
         if (!isset($parsed["host"])) {
             if ($is_root) {
                 $src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
             } else {
                 $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
             }
         }
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     return $images;
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:40,代码来源:OnlineArticle.php

示例3: setData

 /**
  * Set the data to use
  * @param string $data Data to put in the file
  */
 public function setData($data)
 {
     //$data = utf8_encode($data);
     $data = CharacterEntities::convert($data);
     //$data = utf8_decode($data);
     //$this->source = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $data);
     $images = array();
     // image handling stuff
     $dom = new DOMDocument();
     $dom->loadHTML($data) or die($data);
     $dom->normalizeDocument();
     //exit();
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         /*$parsed = parse_url($src);
         	
         				if(!isset($parsed["host"])){
         					if($is_root){
         						$src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
         					}else{
         						$src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
         					}
         				}*/
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     $this->images = $images;
     //end image stuff
     $data = $dom->saveXML();
     $data = str_replace("<pagebreak/>", "<mbp:pagebreak/>", $data);
     $data = str_replace("<pagebreak></pagebreak>", "<mbp:pagebreak/>", $data);
     //			echo $data;
     //			print_r($this->images);
     $this->source = $data;
     $this->prc = false;
 }
开发者ID:smelzo,项目名称:PHP-Digital-Format-Convert-Epub-Mobi-PDF,代码行数:56,代码来源:Mobi.inc.php


注:本文中的ImageHandler::DownloadImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。