Skip to content

Commit

Permalink
album cover not being written to DB - only to file
Browse files Browse the repository at this point in the history
#113
An old obsolete function for the backgroundcolor was called - and this caused the album not to be written.
Furthermore, when a cover was already set, it was not updated/overwritten
  • Loading branch information
Rello authored Jan 15, 2017
1 parent 5536e89 commit a0dd8a7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions controller/scannercontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,7 @@ public function saveAudioFileData() {
$returnData['imgsrc']='';
$returnData['prefcolor'] = '';
if($pImgMime !== '' && $addCoverToAlbum === 'true'){
$getDominateColor = $this->getDominateColorOfImage($imgString);
$this->writeCoverToAlbum($newAlbumId,$imgString,$getDominateColor);

$returnData['prefcolor'] = 'rgba('.$getDominateColor['red'].','.$getDominateColor['green'].','.$getDominateColor['blue'].',0.7)';
$this->writeCoverToAlbum($newAlbumId,$imgString,'');
$returnData['imgsrc'] = 'data:image/jpg;base64,'.$imgString;
}

Expand Down Expand Up @@ -701,14 +698,9 @@ private function writeCoverToAlbum($iAlbumId,$sImage,$aBgColor){
$stmtCount = $this->db->prepareQuery( 'SELECT `cover` FROM `*PREFIX*audioplayer_albums` WHERE `id` = ? AND `user_id` = ?' );
$resultCount = $stmtCount->execute(array ($iAlbumId, $this->userId));
$row = $resultCount->fetchRow();
if($row['cover'] === null){
$aBgColor=json_encode($aBgColor);
$stmt = $this->db->prepareQuery( 'UPDATE `*PREFIX*audioplayer_albums` SET `cover`= ?, `bgcolor`= ? WHERE `id` = ? AND `user_id` = ?' );
$result = $stmt->execute(array($sImage, $aBgColor, $iAlbumId, $this->userId));
return true;
}else{
return false;
}
$stmt = $this->db->prepareQuery( 'UPDATE `*PREFIX*audioplayer_albums` SET `cover`= ?, `bgcolor`= ? WHERE `id` = ? AND `user_id` = ?' );
$result = $stmt->execute(array($sImage, '', $iAlbumId, $this->userId));
return true;
}

/**
Expand Down

0 comments on commit a0dd8a7

Please sign in to comment.