Last.fm Recent Album Artwork Plugin
My blog is now running a WordPress plugin that shows the album covers from Last.fm of songs I've recently listened to. There's a lot of plugins out there, but none that I found that did the job of getting the artwork, and certainly not for the most recent albums.
Download the Last.fm recent album artwork plugin
Last.fm Integration
You'll need a Last.fm account and the iScrobbler running to store the recent tracks at Last.fm. To check, you can view the recent tracks feed changing remysharp to your Last.fm username.
Installing
Download the Last.fm recent album artwork plugin and save it in your plugins directory (usually located in wp-content).
Then activate the plugin from the Plugins tab in your WordPress admin tools.
Setup
Through the Options -> Last.fm Recent Albums tab fill out the required fields.
Album Art Cache Settings
You must ensure the directory that you point the plugin to is writable. You can use either full or relative paths for the album artwork.
For example, my album artwork is located at http://remysharp.com/albums/, so my URL is set to:
/albums/
Within my WordPress set up, this is physically located in /home/remy/remysharp.com/htdocs/albums/, but I've set the path to be relative in the settings, so it reads:
albums/
Since the root of my WordPress installation is /home/remy/remysharp.com/htdocs/ this works just fine.
Adding to your Blog
Once the setup is complete, use the get_lastFM_album_artwork() function to add the album artwork to you blog. My blog adds the code as follows (with the setup wrapping the elements with li)
<?php if (function_exists('get_lastFM_album_artwork')) { ?>
<div class="lastfm">
<h3>Recent Albums</h3>
<ul>
<?php
get_lastFM_album_artwork();
?>
</ul>
</div>
<?php } ?>
Behind the Scenes
Behind the scenes the code will only show album artwork if Last.fm have the album associated (there's a number of tracks that don't have that information linked). If there's not enough recent tracks from the feed, the plugin will fill the rest of the albums based on the recently played albums (using timestamps from the artwork files).
The plugin will also avoid showing the same album cover twice.
Problems?
If you have any problems or suggestions or questions about the plugin, please let me know and I'll do my best to help.
You should follow me on Twitter here I'll tweet about JavaScript, HTML 5 and other such gems (amongst usual tweet-splurges)
Introducing HTML5
[...] Last.fm Recent Album Artwork [...]
Parse error: parse error, unexpected T_OBJECT_OPERATOR in D:\hosting\wwwroot\evanwu_org\htdocs\story\wp-content\plugins\lastfm_albums_artwork.php on line 158
Can u help me to fix?
The API doesn't put the actual album but the one with most listeners where the song appears.
Hey, your plugin has been great. But I was looking at my site recently, and noticed that the Album name had dropped the first letter, the track names were gone, and the $url command was also missing a letter. I assume that last.fm changed something in their feed. Was wondering if you knew what was going on. Here is how I have my code implemented, and I use UL tags with the function on the template:
Hi,
I have installed you plugin on my development site, http://dev.daniel-groves.co.uk, but I cannot seem to get your plugin working properly.
All of the track information displays perfectly, but I don't get any album artwork.
My HTML format is:
I filled out the URl field with: /wp-content/lfmCache/
And the Full Path with: wp-content/lfmCache
I have set the permissions on this folder to 0777.
Even after doing all of this I cannot seem to get the album art to appear.
Is their anything I can do to fix this?
Thanks for all your work,
Dan.
Still loving the plugin, by far the best for display recent tracks from last.fm.
One small problem though...
I just moved host to media temple, since doing so I can't get the album artwork to show (there are no errors).
I'm using a custom directory for the core wordpress files and a custom directory for the media uploads too (other than /wp-content/uploads/ i'm using /wp-content/media/).
All my settings appear to be correct but nothing is showing.
Any ideas?
Cheers!
Dale.
Update to my previous comment for those who are having the same issue...
It turns out that the reason nothing was displaying on my website was because 'allow_url_fopen' was disabled in my PHP configuration.
If you're having the same issue you can fix it by adding the following line to your php.ini file (in some cases your web-host will not allow you to do so):
allow_url_fopen = On