diff --git a/config/config.inc.php b/config/config.inc.php index 0665306..d017463 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -5,16 +5,16 @@ **************************************/ /* Config relating to the display of CD covers */ - /******** THIS IS NOT YET IMPLEMENTED! *********/ - $_CONFIG['music_directory'] = '/var/lib/mpd/music'; + /* music_directory must match you MPD music_directory config */ + $_CONFIG['music_directory'] = '/home/danbee/Music'; $_CONFIG['album_cover_name'] = 'folder.jpg'; - /***********************************************/ + $_CONFIG['album_cover_size'] = 130; /* Template to use for displaying the pages */ $_CONFIG['template'] = 'default'; /* Browse mode can be 'filesystem' or 'metadata' */ - $_CONFIG['browse_mode'] = 'filesystem'; + $_CONFIG['browse_mode'] = 'metadata'; $_CONFIG['sort_by_tracknumber'] = true; diff --git a/lib/global.php b/lib/global.php index 93728d4..e451d10 100644 --- a/lib/global.php +++ b/lib/global.php @@ -1,7 +1,15 @@ $ratio_orig) { + $width = $height*$ratio_orig; + } else { + $height = $width/$ratio_orig; + } + + // Resample + $image_p = imagecreatetruecolor($width, $height); + $image = imagecreatefromjpeg($filename); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + + // Output + imagejpeg($image_p, $cache_file_name, 95); + + } + + echo file_get_contents($cache_file_name); +?> diff --git a/lib/page.php b/lib/page.php index 579aebe..c24df7a 100644 --- a/lib/page.php +++ b/lib/page.php @@ -25,6 +25,16 @@ $smarty->assign('current_album', $current_track['Album']); $smarty->assign('current_artist', $current_track['Artist']); $smarty->assign('current_file', $current_track['file']); + + $cover_link = $_CONFIG['music_directory'] . '/' + . substr($current_track['file'], 0, strrpos($current_track['file'], '/') + 1) + . $_CONFIG['album_cover_name']; + + if (file_exists($cover_link)) { + $smarty->assign('coverimage', $cover_link); + $smarty->assign('coversize', $_CONFIG['album_cover_size']); + } + break; case "browse": @@ -36,7 +46,7 @@ /* split the browse get var if present */ if ($_GET['browse']) { - setcookie('browse', stripslashes($_GET['browse'])); + setcookie('browse', $_GET['browse']); if ($_GET['browse'] == '/') { $meta_level = 'artists'; } @@ -81,7 +91,7 @@ $artists = $mympd->GetArtists(); foreach ($artists as $the_artist) { - $browselist[] = array('metaArtist' => $the_artist, 'path' => stripslashes($the_artist)); + $browselist[] = array('metaArtist' => $the_artist, 'path' => $the_artist); } break; @@ -90,10 +100,10 @@ $albums = $mympd->GetAlbums($artist); foreach ($albums as $the_album) { - $browselist[] = array('metaAlbum' => $the_album, 'path' => stripslashes($artist . '/' . $the_album)); + $browselist[] = array('metaAlbum' => $the_album, 'path' => $artist . '/' . $the_album); } - $dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist)))); + $dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode($artist))); break; @@ -117,7 +127,7 @@ usort($browselist, "track_sort"); } - $dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist))), array('name' => stripslashes($album), 'path' => urlencode(stripslashes($artist . '/' . $album)))); + $dir_list = array(array('name' => $artist, 'path' => urlencode($artist)), array('name' => $album, 'path' => urlencode($artist . '/' . $album))); break; } @@ -132,13 +142,13 @@ /* get the browse position from the cookie or from get */ if ($_GET['browse']) { $browse = $_GET['browse']; - setcookie('browse', stripslashes($browse)); + setcookie('browse', $browse); } else { $browse = $_COOKIE['browse']; } - $browse = stripslashes($browse); + $browse = $browse; /* make the path array */ diff --git a/templates/default/control.html b/templates/default/control.html index 4c6df1c..d4a9acf 100644 --- a/templates/default/control.html +++ b/templates/default/control.html @@ -1,3 +1,5 @@ -