本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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;
}
}
示例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();
}
示例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;
}