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