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


PHP Media::put方法代码示例

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


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

示例1: backup

 function backup()
 {
     global $globals;
     if ($globals['Amazon_S3_media_bucket'] && $globals['Amazon_S3_upload']) {
         return Media::put($this->pathname(), $this->type);
     }
     return true;
 }
开发者ID:manelio,项目名称:woolr,代码行数:8,代码来源:upload.php

示例2: get_thumb

	function get_thumb($debug = false) {
		global $globals;

		$site = false;
		if (empty($this->url)) {
			if (!$this->read()) return false;
		}
		$blog = new Blog();
		$blog->id = $this->blog;
		if ($blog->read()) {
			$site = $blog->url;
		}
		$this->image_parser = new HtmlImages($this->url, $site);
		$this->image_parser->debug = $debug;
		$this->image_parser->referer = $this->get_permalink();
		echo "<!-- Meneame, before image_parser -->\n";
		$img = $this->image_parser->get();
		echo "<!-- Meneame, after image_parser -->\n";
		$this->thumb_status = 'checked';
		$this->thumb = '';
		if ($img) {
			$filepath = mnmpath.'/'.$globals['cache_dir'];
			@mkdir($filepath);
			$chain = get_cache_dir_chain($this->id);
			create_cache_dir_chain($filepath, $chain);
			$filepath .= "/$chain/thumb-$this->id.jpg";
			if ($img->type == 'local') {
				$img->scale($globals['thumb_size']);
				if($img->save($filepath)) {
					@chmod($filepath, 0777);
					$this->thumb_x = $img->x;
					$this->thumb_y = $img->y;
					// Upload to S3
					if ($globals['Amazon_S3_media_bucket'] && $globals['Amazon_S3_media_url'] && Media::put($filepath, 'thumbs', "$this->id.jpg")) {
							//$this->thumb = $globals['Amazon_S3_media_url'] . "/thumbs/$this->id.jpg";
							$this->thumb_status = 'remote';
					} else {
						//$this->thumb = $globals['base_url'].$globals['cache_dir'].'/thumbs';
						//$this->thumb .= "/$chain/$this->id.jpg";
						$this->thumb_status='local';
					}
					syslog(LOG_NOTICE, "Meneame, new thumbnail $img->url to " . $this->get_permalink());
					if ($debug)
						echo "<!-- Meneame, new thumbnail $img->url -->\n";
				} else {
					$this->thumb_status = 'error';
					if ($debug)
						echo "<!-- Meneame, error saving thumbnail ".$this->get_permalink()." -->\n";
				}
			}
			if ($img->video) $this->content_type = 'video';
		} elseif ($this->thumb_x || $this->thumb_y) {
			$this->delete_thumb();
			return false;
		}
		$this->store_thumb();
		return $this->has_thumb();
	}
开发者ID:rasomu,项目名称:chuza,代码行数:58,代码来源:link.php

示例3: put

 /**
  * Shortcut for putting an asset into the correct silo based on its path
  *
  * @return boolean True on success
  */
 public function put()
 {
     return Media::put($this);
 }
开发者ID:anupom,项目名称:my-blog,代码行数:9,代码来源:mediaasset.php

示例4: copy

 /**
  * Copy the asset using the specified from and to paths
  *
  * @param string $pathfrom The virtual path source
  * @param string $pathto The virtual path destination
  * @return boolean true on success
  */
 public static function copy($pathfrom, $pathto)
 {
     if ($source = Media::get($pathfrom)) {
         return Media::put($pathto, $source);
     } else {
         return false;
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:15,代码来源:media.php

示例5: get_thumb

 function get_thumb($debug = false, $url = false)
 {
     global $globals;
     $site = false;
     if (empty($this->url)) {
         if (!$this->read()) {
             return false;
         }
     }
     $blog = new Blog();
     $blog->id = $this->blog;
     if ($blog->read()) {
         $site = $blog->url;
     }
     if (!empty($url)) {
         $this->image_parser = new HtmlImages($url);
     } else {
         $this->image_parser = new HtmlImages($this->url, $site);
         $this->image_parser->debug = $debug;
         $this->image_parser->referer = $this->get_permalink();
     }
     if ($debug) {
         echo "<!-- Meneame, before image_parser -->\n";
     }
     $img = $this->image_parser->get();
     if ($debug) {
         echo "<!-- Meneame, after image_parser: {$img->url} -->\n";
     }
     $this->thumb_status = 'checked';
     $this->thumb = '';
     if ($img) {
         Upload::create_cache_dir($this->id);
         $filepath = Upload::get_cache_dir($this->id) . "/thumb-{$this->id}.jpg";
         $oks = 0;
         if ($img->type == 'local') {
             foreach (Link::thumb_sizes() as $b => $s) {
                 $filepath = Upload::get_cache_dir($this->id) . "/{$b}-{$this->id}.jpg";
                 $thumbnail = $img->scale($s);
                 $res = $thumbnail->save($filepath);
                 if (!$res) {
                     continue;
                 }
                 $oks++;
                 @chmod($filepath, 0777);
                 if ($b == 'thumb') {
                     $this->thumb_x = $thumbnail->getWidth();
                     $this->thumb_y = $thumbnail->getHeight();
                 }
                 if ($b == 'thumb_medium' && $globals['Amazon_S3_media_bucket']) {
                     Media::put($filepath, 'thumbs', "medium_{$this->id}.jpg");
                 }
             }
             if ($oks > 0) {
                 // syslog(LOG_NOTICE, "Meneame, new thumbnail $img->url to " . $this->get_permalink());
                 if ($debug) {
                     echo "<!-- Meneame, new thumbnail {$img->url} -->\n";
                 }
             } else {
                 $this->thumb_status = 'error';
                 if ($debug) {
                     echo "<!-- Meneame, error saving thumbnail " . $this->get_permalink() . " -->\n";
                 }
             }
         }
     } elseif ($this->thumb_x || $this->thumb_y) {
         $this->delete_thumb();
         return false;
     }
     $this->store_thumb();
     return $this->has_thumb();
 }
开发者ID:manelio,项目名称:woolr,代码行数:71,代码来源:link.php

示例6: avatars_db_store

function avatars_db_store($user, $file, $now)
{
    global $db, $globals;
    // Store in S3
    if ($globals['Amazon_S3_media_bucket']) {
        if (Media::put($file, 'avatars')) {
            $db->query("update users set user_avatar = {$now}  where user_id={$user}");
            return $now;
        } else {
            return false;
        }
    }
    // Store locally
    $bytes = file_get_contents($file);
    if (strlen($bytes) > 0 && strlen($bytes) < 30000) {
        $bytes = addslashes($bytes);
        $db->query("replace into avatars set avatar_id = {$user}, avatar_image='{$bytes}'");
        $db->query("update users set user_avatar = {$now}  where user_id={$user}");
        return $now;
    }
    return false;
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:22,代码来源:avatars.php


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