Update: this widget uses an XML-feed from Last.fm that doesn’t update regularly. I have written a new widget: Run for cover. It uses a page at Last.fm that updates every week. More information here.

Turned my bit of PHP for displaying cd covers into a widget for WordPress. It reads the top-albums feed for a last.fm username and displays the covers for the cds.

  1. Download version 1.3 Go here for my new last.fm covers widget.
  2. Extract, drop lastfmcovers.php in /wp-content/plugins/widgets and configure it under the “sidebar widgets” tab in WordPress.

Settings include:

  • title: displayed at the top of the widget
  • username: last.fm username to display cd covers for (no password needed)
  • max displayed: number of images to display
  • description for count: text used in alt/title-tag of the images, % will be replaced with ‘count’
  • image size: pixels for image width and height. Set this to zero to use img.lastfmimage in your stylesheet

What it needs:

  • check if username exists
  • sample stylesheet code
  • suggestions

Update: last.fm changed their “no_album” image, so if you see little grey circles in your sidebar, please install the current version — version 1.3 is now really 1.3.00001.

38 reacties

Joseph 5 mei 2006 Reageer

dog of Dirk,

I am experiencing a problem using WordPress 2.02 and the Last.fm Covers plugin. I hope you can help me see my mistake. I took screenshots of what I did.

1. I placed the lastfmcovers.php in /wp-content/plugins/widgets:


2. I have the Widget plugin and I have activated both the Widgit and the Last.fm Covers plugin:


3. The widget appears in my widget list screen and I have entered the data for my Last.fm user name:


I have selected “0” for Image Size and I am using the following line in my CSS:

img.lastfmimage {padding: 1px; border: 1px solid #333333; margin: 3px; width: 50px; }

4. My topalbums.xml file works on the Last.fm website:


5. But the widget is still not visible on the sidebar of my website:


Am I making a basic error I cannot see? Thank you for your consideration.

Laurent 6 mei 2006 Reageer

Hi ! Thx for your work

I’m getting the following error :

Warning: Invalid argument supplied for foreach() in /home/victoire/www/wp-content/plugins/widgets/lastfmcovers.php on line 46

any idea ?

hondjevandirkie 6 mei 2006 Reageer

Laurent, I have uploaded version 1.2:

added some extra checks
widget displays a message when there are no cd covers to display
removed the hard maximum of 24 covers

Laurent 11 mei 2006 Reageer

Great : it works now !! see my blog (http://www.victoire-technologies.org)

=> all i had to do was to way for my “top album” feed to be generated (couple of days)


Ryan 29 mei 2006 Reageer

Hey guys. I got this installed okay, it seems. I placed the widget into the sidebar and adjusted the username. It still just says “No cd covers to display” I KNOW there there are. I went to my list of most recently played songs, clicked on the most recent ones only to find that they DO have album covers attached.

Here are my settings:
Title: Last.fm
Username: slant675
Max displayed: 6
Description for count: % times.
Image size: 70

For the most part, I thought this was default. The error blantently alludes to the fact that it is working logic-wise at least. The problem is that where the widget is looking, last.fm is not telling it that album covers exist for what I’ve been listening to.

Thoughts? Thanks!!!

hondjevandirkie 29 mei 2006 Reageer

Hi Ryan,

I asked around on the last.fm forums as this is reported often. It seems that it takes some time for your feed to show album covers. I checked your feed at


and it is empty, so you probably have to be patient. I’m hoping for a new topalbums feed, but there’s no info yet.

Thanks for installing the widget!

Ryan 29 mei 2006 Reageer

Furthermore, my AudioScrobbler page (http://ws.audioscrobbler.com/1.0/user/slant675/topalbums.xml) does not seem to have anything in it. How bizaar. Is this normal? I’ve used the AudioScrobbler plugin to gather a few songs, but I have mostly been using http://pandorafm.real-ity.com/ (starting today – heh).

This seems to skip the AudioScrobbler plugin altogether, though I’m not certain. Does this change anything?

Awesome-looking plugin!! I can’t wait to get it working, I have 6 other blogs hosted on my site also, so they can’t use it either. 🙁

Thanks so much!!

Brian 31 mei 2006 Reageer

Anybody know how to contain the box that holds all the albums? I have the covers displaying just fine, but they extend outside of my sidebar, and it creates a rather ugly overlap. See it here: http://www.superbrian.org. See what I mean?

Sorry if this is a very basic question. I’m rather new at this. Thanks.


supagold 8 juni 2006 Reageer

Your widget looks really cool, but I can’t seem to get it to work on my site. When I set all the options, my username doesn’t seem to persist as a setting. Every other setting remains, but when I go back in to check the settings, the username field has been blanked out. I tried checking the feed URL you gave to Ryan above, but replaced slant675 with my username, nixoncd, and my feed was there. Any suggestions?

hondjevandirkie 8 juni 2006 Reageer

Hi supagold — I tried setting your username on my own weblog and this works ok, as expected. You could mail me the other settings for the widget, presuming you changed them, so I can try to find out what happens.

This widget uses the standard WordPress system for settings, so it’s hard to say what’s happening here.

IronMAN 16 juni 2006 Reageer


I got this installed okay, it seems. I placed the widget into the sidebar and adjusted the username. It still just says “No cd covers to display”

my settings:
Title: Last.fm
Username: IronMANro
Max displayed: 4
Description for count: % times.
Image size: 70

I checked http://ws.audioscrobbler.com/1.0/user/IronMANro/topalbums.xml, its seems to be ok.

i use the audioscrobbler from 4 months ago.

what i need to do?

hondjevandirkie 19 juni 2006 Reageer

Hi IronMAN,

I have been looking at your site and my widget but can’t find anything wrong with it. It could be a simple rights question — the php opens a socket to get the feed. If you’re not allowed to do that on your server, it can’t read the feed.

Also have you double checked that wordpress has saved the settings?

I also set my own widget to your username and that showed the covers ok.

Good luck!

Alok 4 juli 2006 Reageer

hey, I installed, and activated the widget… added the details..all of it default. username : salok
seems to be full of all the albums i’ve heard..but the plugin still doesnt seem to work… does my host need to have cURL or fOPEN? I have neither.. as i’m using a free hosting service. please help.

hondjevandirkie 4 juli 2006 Reageer

Hi Alok,

yes, the widget uses fopen to read the xml feed from last.fm

John 8 juli 2006 Reageer

Any chance you want to create a Dreamhost-friendly (that is, with an fopen workaround) version of your plugin? I use Dreamhost, and LOVE your plugin, but can’t get it to work.

hondjevandirkie 8 juli 2006 Reageer

Hi John, you could try version 1.3 — I have tried to add cUrl to the widget. Let me now if this solves your issue!

John 8 juli 2006 Reageer

Version 1.3 works beautifully! Thanks for the update!

Archie Binnie 16 juli 2006 Reageer

I’ve added some functionality to your Last.fm covers widget. It now has a new feature, configurable through the usual front end, which allows users to optionally enclose the cover images in a div element, styled to be margin and border less and with the alignment of their choice. This allows the cover images to be centered, right and left aligned in a sidebar, and other graphical treatments, while keeping the title still formatted according to $before_title and $after_title variables.

This could also be achieved by adding bits to $after_title and $after_widget, but this would also alter all widget content from other widgets. In my specific case I wanted my blogroll list left aligned, my covers center aligned, but both headings left aligned.

This is my first go at PHP coding, so expect a bug or two… I’d like to send you the additions for consideration for inclusion in the next version, but I can’t find your email address.

ron 26 juli 2006 Reageer

Hello, I am wondernig if this widget is possible with a non widget call function? My template doesnt use widgets 🙁

hondjevandirkie 26 juli 2006 Reageer

HI Ron, I’m working on a last.fm plugin. Watch this page, but not for the coming two weeks as I’ll be on holiday and I promised not to bring my laptop. 😉

Gunnar 31 juli 2006 Reageer

How can i remove the Borders around the Covers?


hondjevandirkie 3 augustus 2006 Reageer

Hi Gunnar, if you set image size in the options to zero, you can then use img.lastfmimage in your stylesheet.

Pingback: English
mcbobo 4 oktober 2006 Reageer

What about making a folder for chaching the album covers once a day? That would save time on page load.

hondjevandirkie 4 oktober 2006 Reageer

Caching is something I’m working on for my new last.fm plugin (instead of widget) for wordpress. Version 0.01b somewhere this year 😉

Thomas van der Westen 26 oktober 2006 Reageer

Ha dirk!

(mijn engels is niet zo best)
Hello, I am wondernig if this widget is possible with a non widget call function? My template doesnt use widgets 🙁

^ the same for my..

are you working on it? 😀


Paul 28 oktober 2006 Reageer

Thanks for making this available, it works well.

Guillaume 1 november 2006 Reageer

I think something might have just changed on the last.fm side of things. It seems that they had a few updates in the last few hours and for the first time today I get this message instead of the covers in my sidebar:
“No cd covers to display”

Coincidence? Maybe, maybe not. You tell us.

XIII 6 november 2006 Reageer

Hoi Dirk, I’m also using a Hemingway flavored theme so I’d love to get my hands on the code you use for the covers. Clean or not. 😉

manuch 14 november 2006 Reageer

Thank you!! that worked perfect, took me a while to figure out. I’m just a newbiew!! thank you 🙂

manira 20 november 2006 Reageer

Hi. I’d like to point out that the link to the run for cover widget is dated for the 14th, not the 15th, so the link should be: https://dirkie.nu/2006/11/14/run-for-cover/

hondjevandirkie 20 november 2006 Reageer

Manira, thanks! I corrected the link.

Geef een reactie