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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...