Jump to content

[SOLVED] Save image from URL to images field in repeater via API

Recommended Posts

I'm working with an XML feed which provides image URLs that I want to save to an images field in a repeater. So far I have this:

foreach($page->goodreads as $goodreads) :

  $xml_string = $cache->get($goodreads->isbn, 3600, function() use($goodreads_api, $goodreads) {
    return curl_get_contents('https://www.goodreads.com/search/index.xml?key='.$goodreads_api.'&q='.$goodreads->isbn);
  $book_xml = new SimpleXMLElement($xml_string);

  foreach ($book_xml->search->results->work as $book) :




I've tested that $book->best_book->image_url does actually return a value and have also tested the above with a hard-coded image URL but in both cases, no image is saved. What am I missing?

Share this post

Link to post
Share on other sites

Figured it out in the end. Coded above would work fine, but I had other conditionals in place which were preventing parts of it from running.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...