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


PHP Art::extension方法代码示例

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


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

示例1: file_get_contents

                $defaultimg .= "blankmovie.png";
                break;
            default:
                $mime = 'image/png';
                $defaultimg .= "blankalbum.png";
                break;
        }
        $image = file_get_contents($defaultimg);
    } else {
        if ($_GET['thumb']) {
            $thumb_data = $art->get_thumb($size);
            $etag .= '-' . $_GET['thumb'];
        }
        $mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime;
        $image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw;
    }
}
if (!empty($image)) {
    $extension = Art::extension($mime);
    $filename = scrub_out($filename . '.' . $extension);
    // Send the headers and output the image
    $browser = new Horde_Browser();
    if (!empty($etag)) {
        header('ETag: ' . $etag);
        header('Cache-Control: private');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time()));
    }
    header("Access-Control-Allow-Origin: *");
    $browser->downloadHeaders($filename, $mime, true);
    echo $image;
}
开发者ID:bl00m,项目名称:ampache,代码行数:31,代码来源:image.php

示例2: dump_album_art

 /**
  * dump_album_art
  *
  * This runs through all of the albums and tries to dump the
  * art for them into the 'folder.jpg' file in the appropriate dir.
  */
 public function dump_album_art($methods = array())
 {
     // Get all of the albums in this catalog
     $albums = $this->get_album_ids();
     echo "Starting Dump Album Art...\n";
     $i = 0;
     // Run through them and get the art!
     foreach ($albums as $album_id) {
         $album = new Album($album_id);
         $art = new Art($album_id, 'album');
         if (!$art->get_db()) {
             continue;
         }
         // Get the first song in the album
         $songs = $album->get_songs(1);
         $song = new Song($songs[0]);
         $dir = dirname($song->file);
         $extension = Art::extension($art->raw_mime);
         // Try the preferred filename, if that fails use folder.???
         $preferred_filename = AmpConfig::get('album_art_preferred_filename');
         if (!$preferred_filename || strpos($preferred_filename, '%') !== false) {
             $preferred_filename = "folder.{$extension}";
         }
         $file = "{$dir}/{$preferred_filename}";
         if ($file_handle = fopen($file, "w")) {
             if (fwrite($file_handle, $art->raw)) {
                 // Also check and see if we should write
                 // out some metadata
                 if ($methods['metadata']) {
                     switch ($methods['metadata']) {
                         case 'windows':
                             $meta_file = $dir . '/desktop.ini';
                             $string = "[.ShellClassInfo]\nIconFile={$file}\nIconIndex=0\nInfoTip={$album->full_name}";
                             break;
                         case 'linux':
                         default:
                             $meta_file = $dir . '/.directory';
                             $string = "Name={$album->full_name}\nIcon={$file}";
                             break;
                     }
                     $meta_handle = fopen($meta_file, "w");
                     fwrite($meta_handle, $string);
                     fclose($meta_handle);
                 }
                 // end metadata
                 $i++;
                 if (!($i % 100)) {
                     echo "Written: {$i}. . .\n";
                     debug_event('art_write', "{$album->name} Art written to {$file}", '5');
                 }
             } else {
                 debug_event('art_write', "Unable to open {$file} for writing", 5);
                 echo "Error: unable to open file for writing [{$file}]\n";
             }
         }
         fclose($file_handle);
     }
     echo "Album Art Dump Complete\n";
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:65,代码来源:catalog.class.php


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