summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 07:21:47 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 07:21:47 +0000
commit755ab35f6b6b0e78bbff6ca24f3f44008d9a4f71 (patch)
treebef53f58330458ed620afd0e9ada526355d99ff7
parentee9999a93074c737ffc298c8370ef05a3121cfa0 (diff)
downloadampache-755ab35f6b6b0e78bbff6ca24f3f44008d9a4f71.tar.gz
ampache-755ab35f6b6b0e78bbff6ca24f3f44008d9a4f71.tar.bz2
ampache-755ab35f6b6b0e78bbff6ca24f3f44008d9a4f71.zip
fixed the album art gathering, enabled art resizing and saving of said stuff... not sure if saving and retriving is saving any time. tweaked show test config wording
-rw-r--r--albums.php3
-rw-r--r--image.php20
-rw-r--r--lib/album.lib.php10
-rw-r--r--lib/class/album.class.php29
-rw-r--r--lib/class/random.class.php2
-rw-r--r--lib/ui.lib.php14
-rw-r--r--templates/rightbar.inc.php1
-rw-r--r--templates/show_test_config.inc.php2
8 files changed, 56 insertions, 25 deletions
diff --git a/albums.php b/albums.php
index 9c97163b..ef5b0aa5 100644
--- a/albums.php
+++ b/albums.php
@@ -116,11 +116,10 @@ switch ($_REQUEST['action']) {
if (count($images)) {
// We don't want to store raw's in here so we need to strip them out into a seperate array
foreach ($images as $index=>$image) {
- if (isset($image[$index]['raw'])) {
+ if ($image['raw']) {
unset($images[$index]['raw']);
}
} // end foreach
-
// Store the results for further use
$_SESSION['form']['images'] = $images;
require_once Config::get('prefix') . '/templates/show_album_art.inc.php';
diff --git a/image.php b/image.php
index 8bd6d5e3..b7c98b8e 100644
--- a/image.php
+++ b/image.php
@@ -72,24 +72,28 @@ switch ($_REQUEST['type']) {
// Attempt to pull art from the database
$art = $album->get_art();
- if (!$art['art_mime']) {
+ if (!$art['mime']) {
header('Content-type: image/gif');
readfile(Config::get('prefix') . Config::get('theme_path') . '/images/blankalbum.gif');
break;
} // else no image
// Print the album art
- $data = explode("/",$art['art_mime']);
+ $data = explode("/",$art['mime']);
$extension = $data['1'];
-// if (empty($_REQUEST['thumb'])) {
- $art_data = $art['art'];
-// }
- //else {
- // $art_data = img_resize($art,$size,$extension,$_REQUEST['id']);
- //}
+ if (empty($_REQUEST['thumb'])) {
+ $art_data = $art['raw'];
+ }
+ else {
+ $art_data = img_resize($art,$size,$extension,$_REQUEST['id']);
+ }
// Send the headers and output the image
+ header("Expires Sun, 19 Nov 1978 05:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Pragma: no-cache");
header("Content-type: $mime");
header("Content-Disposition: filename=" . $album->name . "." . $extension);
echo $art_data;
diff --git a/lib/album.lib.php b/lib/album.lib.php
index 9b76d9a9..8812cb4c 100644
--- a/lib/album.lib.php
+++ b/lib/album.lib.php
@@ -38,6 +38,16 @@ function get_image_from_source($data) {
return $data['raw'];
}
+ // If it came from the database
+ if (isset($data['db'])) {
+ // Repull it
+ $album_id = Dba::escape($data['db']);
+ $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'";
+ $db_results = Dba::query($sql);
+ $row = Dba::fetch_assoc($db_results);
+ return $row['art'];
+ } // came from the db
+
// Check to see if it's a URL
if (isset($data['url'])) {
$snoopy = new Snoopy();
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index bc383f7c..62e6ac8c 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -216,7 +216,7 @@ class Album {
$art = $this->get_db_art();
}
- return $art;
+ return $art['0'];
} // get_art
@@ -259,9 +259,9 @@ class Album {
case 'get_amazon_art':
$data = $this->{$method_name}($options['keyword'],$limit);
break;
- case 'get_id3_art':
- $data = $this->{$method_name}($limit);
- break;
+ case 'get_lastfm_art':
+ $data = $this->{$method_name}($limit,$options);
+ break;
default:
$data = $this->{$method_name}($limit);
break;
@@ -288,12 +288,21 @@ class Album {
* This returns the art as pulled from lastFM. This doesn't require
* a special account, we just parse and run with it.
*/
- public function get_lastfm_art($limit) {
+ public function get_lastfm_art($limit,$options='') {
// Create the parser object
$lastfm = new LastFMSearch();
- $raw_data = $lastfm->search($this->artist_name,$this->name);
+ if (is_array($options)) {
+ $artist = $options['artist'];
+ $album = $options['album_name'];
+ }
+ else {
+ $artist = $this->artist_name;
+ $album = $this->name;
+ }
+
+ $raw_data = $lastfm->search($artist,$album);
if (!count($raw_data)) { return array(); }
@@ -446,7 +455,9 @@ class Album {
}
else { return false; }
- return $results;
+ $data = array(array('db_resized'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime']));
+
+ return $data;
} // get_resized_db_art
@@ -462,8 +473,10 @@ class Album {
$results = Dba::fetch_assoc($db_results);
if (!$results['art']) { return array(); }
+
+ $data = array(array('db'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime']));
- return $results;
+ return $data;
} // get_db_art
diff --git a/lib/class/random.class.php b/lib/class/random.class.php
index b24845e8..58be0463 100644
--- a/lib/class/random.class.php
+++ b/lib/class/random.class.php
@@ -32,7 +32,7 @@ class Random {
* Constructor
* nothing to see here, move along
*/
- private function __construct($id) {
+ public function __construct() {
// Rien a faire
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index b89b4fea..ff863c78 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -514,15 +514,15 @@ function img_resize($image,$size,$type,$album_id) {
/* Make sure they even want us to resize it */
if (!Config::get('resize_images')) {
- return $image['art'];
+ return $image['raw'];
}
// Already resized
- if ($image['resized']) {
+ if ($image['db_resized']) {
debug_event('using_resized','using resized image for Album:' . $album_id,'2');
- return $image['art'];
+ return $image['raw'];
}
- $image = $image['art'];
+ $image = $image['raw'];
if (!function_exists('gd_info')) { return false; }
@@ -541,7 +541,10 @@ function img_resize($image,$size,$type,$album_id) {
$src = imagecreatefromstring($image);
- if (!$src) { return false; }
+ if (!$src) {
+ debug_event('IMG_RESIZE','Failed to create from string','3');
+ return false;
+ }
$width = imagesx($src);
$height = imagesy($src);
@@ -552,6 +555,7 @@ function img_resize($image,$size,$type,$album_id) {
$img = imagecreatetruecolor($new_w,$new_h);
if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) {
+ debug_event('IMG_RESIZE','Failed to copy resample image','3');
return false;
}
diff --git a/templates/rightbar.inc.php b/templates/rightbar.inc.php
index 73104e3c..8ff3e856 100644
--- a/templates/rightbar.inc.php
+++ b/templates/rightbar.inc.php
@@ -44,6 +44,7 @@
$object->format();
}
else {
+ $object = new Random();
$object->f_link = Random::get_type_name($object_data['1']);
}
?>
diff --git a/templates/show_test_config.inc.php b/templates/show_test_config.inc.php
index 986fb263..c5a6abb3 100644
--- a/templates/show_test_config.inc.php
+++ b/templates/show_test_config.inc.php
@@ -47,7 +47,7 @@ If you are upgrading from 3.3.x please see the directions below.</p>
<h3>Migrating from 3.3.x to 3.4.x</h3>
<p>Ampache 3.4 uses a different config parser that is over 10x faster then the previous version. Unfortunately the new parser is
-unable to read the old config files. You must run <strong>/bin/migrate_config.inc</strong> from the command line to create your
+unable to read the old config files. You must run <strong>php /bin/migrate_config.inc</strong> from the command line to create your
new config file.</p>
<p>The following settings will not be migrated by the <strong>migrate_config.inc</strong> script due to major changes between versions. The default