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
just recently switched to wordpress (from serendipity)... so I have to add code in wordpress templates in order to get plugins visible?
@Gareth - I'm not sure about sidebar widgets, I'll have a look.
@Kimatg - you should be able to easily convert the plugin in to a standalone. There are two lines at the end, one commented out and one not - just switch around the comments like so:
Then in the
get_lastFM_album_artworkfunction, there's a block where my test variables are - uncomment it, and comment out the code below up to the// code startscomment. That should be it.@Mike - That's right - you need to insert the code as per the "Adding to your Blog" in the post above.
Would love the PHP4 version, I get the error too.
Many thanks.
Hi there!!
First of all, thanks for this great plugin!!
I have a problem
I'm trying to run it as standalone, I had made a:
and in ur .php file I had uncommented ur test variables, and write mines, ofc commented the next get_option lines.
Also in the file's bottom I had commented add_action and uncomment the next line, but I recive this error msg:
and its impossible to remove!!! I had tried to put a die; in the first line and the error still appears!
158 line contais:
of the funcition nodeValue but I still have the error commenting it or putting a return true;
I don't know what I can do!!
Greets from Spain
Hey, Me again
I just started getting this message on my wordpress, can't even get into my admin panel.
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/daleanth/public_html/blog/wp-content/plugins/lastfm_albums_artwork.php on line 158
I don't think I have changes any files recently so not to sure what is causing this.
@Dale + @ Ignacio - are you using php 4 or php 5?
PHP5, I tried also to remove manually some parts of PHP4 code but I failed also
Its more hard that I thought to run it at standalone
Is there any way to make the album art image act as the url as well? without displaying the written url?
aha, I'm most likely using php4 - that's my question answered!
Any updates on how the new version is coming?
Hi,
great plugin. Does anyone knows why the first letters are missing? It would be great if it also fetches the album year ...
Check http://www.gamito.net/blog.
Now i realized that tracks are missing too.
My code is:
$artwork
$artist($year) $album$track
Thanks.
[...] Visit [...]
Woohoo!! This plugin looks HOT! I've seen the other Last.FM plugins that have the ability to include a timestamp of when the track was played. This one comes to mind:
http://wordpress.org/extend/plugins/lastfm-for-wordpress/
Would it be possible to include that? Thanks!!
[...] WP官方下载页面 | 插件作者下载页面 [...]
Hey again,
How often is this plugin setup to refresh the data? I have listened to a ton of songs today and it hasn't updated my recently played this evening.
Is there an option anywhere to change the frequency of the updates?
@Dale - the update happens each time the page is requested. Once the page is called, and the function called (i.e. from your sidebar), it will pull the RSS feed from last.fm.
Sometimes their feed goes down, or doesn't update - so you might be seeing this.
On the other hand, the plugin is designed not to show the same album artwork twice, so it depends on the songs you've listened too.
Finally, there's logic so say, only display albums that have enough details to get the artwork and album name. Sometimes last.fm don't have all the details, so those albums are skipped over.
I'd recommend checking the feed and seeing what you've got there first. Cheers.
Hi,
I'm using PHP4 as well, and was just wondering how the cross compatible version was coming along? I would love to get this working on my blog!
Alex
I'm trying to install your plugin to my sidebar. I've changed my username in the PHP file, set up iScrobbler, and And inserted the code into my sidebar but I keep getting and erroe which reads:
Album path must exist and be read/write permissions ()
What should i do?
-JB
@JB - the 'Album Art Cache' directory needs to have write permissions as done like this (assuming the same directories as the post above):
Hi,
Great plugin, just what I was looking for. However, I've followed your instructions and I'm getting the following error:
#
I know this looks like a file permissions error but I've done a chmod on the newly created directory:
/home/users/website.co.uk/lastfm/
It is currently set to 777. I'm also running PHP 5 and Wordpress 2.3 (latest at the time of writing).
Any ideas what could be wrong?
Cheers
Ok, I've sorted the above problem. It was my own stupid mistake of not pointing the full path to the right directory
However, now there are no errors at all but it also isn't displaying any items. I've checked my xml feed and there are items there being updated as I listen but they just aren't showing up on my blog.
I have the following html format:
$artwork
$artist
$track