From the BlogSubscribe Now

Archives for August 2015

How to get a larger album cover image from iTunes API

I ran into this issue recently. I wanted a larger version than what’s returned from the basic response API search. The images there are intended for mobile applications and are available at 60 wide and 100 wide. Easy to get those. What are you going to do with it though? Take a look at the size of the largest version returned from the API.

But how do you get a larger version if your web application requires it? It doesn’t mention anything in the API documents.

Hence a bit of search and replace…take a look at this returned url from the basic api search.

http://is4.mzstatic.com/image/pf/us/r30/Music/ff/c9/01/mzi.jornkthw.100x100-75.jpg

Now all you need to do is replace where it says 100×100 with any value. Need an image that’s 400×400 wide? Change the values to equal that and you’re good to go.

A simple php string replace should do the trick. Here’s what I used to get a 200×200 version of the album.

$albumArt = $response->results[0]->artworkUrl100;
$albumArt = str_replace('100x100', '200x200', $albumArt);

I received the response from the iTunes search library made by Vinelab