Planned Downtime

All Archaic Binary Services, Servers, and Websites will be unavailable for 30 minutes starting at 10:00 AM EST. We are updating the VM infrastructure.

Sonerezh Album Covers

Home/How To/Sonerezh Album Covers

Sonerezh Album Covers

Sonerezh is a self-hosted music streaming platform that is still fairly young. It works very well, until I recently updated to PHP7. I had to manually update the CakePHP libraries that came with it to get past a error “String is a built in function”. After I fixed that error, I decided to try and get the album cover images working.

By default Sonerezh pulls the album covers from the mp3 files themselves via the ID3 info, but I don’t keep those tags when I clean my mp3 files up I have the album art stored as ‘folder.jpg’ in the album folder itself. So I started to dig around and came up with a simple solution that works for me.

Edit the file SongsController.php inside the app/Controllers folder. Around line 93 or so it starts with pulling the photos out of the ID3 information. I added a new section and commented out the old, as displayed below:

if (!empty($songInfo['comments']['genre'])) { $genre_array_length = count($songInfo['comments']['genre']); $newSong['genre'] = $songInfo['comments']['genre'][$genre_array_length - 1]; } $extension = 'jpg'; $name = md5($newSong['artist'].$newSong['album']); $path = IMAGES.THUMBNAILS_DIR.DS.$name.'.'.$extension; if (!file_exists($path)) { if (!file_exists(IMAGES.THUMBNAILS_DIR)) { new Folder(IMAGES.THUMBNAILS_DIR, true, 0777); } if (copy("/...music path here.../".$newSong['artist']."/folder.jpg", $path)) { $newSong['cover'] = $name.'.'.$extension; } } /* if (isset($songInfo['comments']['picture'])) { if (isset($songInfo['comments']['picture'][0]['image_mime'])) { $mime = preg_split('/\//', $songInfo['comments']['picture'][0]['image_mime']); $extension = $mime[1]; } else { $extension = 'jpg'; } $name = md5($newSong['artist'].$newSong['album']); $path = IMAGES.THUMBNAILS_DIR.DS.$name.'.'.$extension; if (!file_exists($path)) { if (!file_exists(IMAGES.THUMBNAILS_DIR)) { new Folder(IMAGES.THUMBNAILS_DIR, true, 0777); } $file = fopen($path, "w"); fwrite($file, $songInfo['comments']['picture'][0]['data']); fclose($file); } $newSong['cover'] = $name.'.'.$extension; } */ } if (!isset($newSong['title'])) {
By |January 15th, 2016|0 Comments

About the Author:

Systems Administrator and hardware hacker who hates social media and posts stuff on this site when he feels like it. That's really about it.

Leave A Comment