Wordpress BookCover
From Fxp Wiki
Here is a little hack for the bookcover extension of wordpress
function ideathinking_bookcover_getdefaultdata() { /* country code 2 book store image url 89: korean 4 : japan : other countries */ $cc2bookstore = array( '978' => '<a href="http://www.amazon.fr/gp/product/${isbn}?ie=UTF8&tag=httpwwwfxpa03-21&linkCode=as2&camp=1642&creative=6746&creativeASIN=${isbn}"><img border="0" src="http://ec2.images-amazon.com/images/P/${isbn}.08.jpg"></a>', '2' => '<a href="http://www.amazon.fr/gp/product/${isbn}?ie=UTF8&tag=httpwwwfxpa03-21&linkCode=as2&camp=1642&creative=6746&creativeASIN=${isbn}"><img border="0" src="http://ec2.images-amazon.com/images/P/${isbn}.08.jpg"></a>', '89' => 'http://isbn.sfreaders.org/cgi-bin/isbnview?isbn=${isbn}', '4' => 'http://bookweb.kinokuniya.co.jp/imgdata/${isbn}.jpg', '' => 'http://images.amazon.com/images/P/${isbn}.01.MZZZZZZZ.gif' ); return $cc2bookstore; } function ideathinking_bookcover_preg_callback($matches) { $cc2bookstore = get_option(BOOKCOVER_NAME); if ($cc2bookstore == null) { $cc2bookstore = ideathinking_bookcover_getdefaultdata(); } foreach ($cc2bookstore as $key => $value) { if ($key == '') { $pos = 0; } else { $pos = strpos("$matches[1]", "$key"); } if ($pos === 0) { if ($key==978){ $shortISBN = substr($matches[1], 3); $shortISBN = substr($shortISBN, 0, -1)."X"; $url = str_replace('${isbn}', $shortISBN, $value); }else{ $url = str_replace('${isbn}', $matches[1], $value); } $alt = "ISBN: $matches[1]"; if ($matches[3] != '') { $alt = $matches[3]; } //return '<img class="bookcover" alt="' . $alt . '" src="' . $url . '" />'; return $url; } } }
Date:Jul/13/08
Categories: Wordpress | Amazon | Source Code | Blog
