diff --git a/ting_covers.pages.inc b/ting_covers.pages.inc index 109acb9..728904a 100644 --- a/ting_covers.pages.inc +++ b/ting_covers.pages.inc @@ -8,12 +8,19 @@ /** * Return the URL for the cover of an object. */ -function ting_covers_objects() { +function ting_covers_objects($http_request = TRUE, $cover_data = array()) { $covers = array(); $image_styles = array(); $missing_images_local_ids = array(); - foreach ($_POST['coverData'] as $cover_info) { + if ($http_request) { + $cover_data = $_POST['coverData']; + } + elseif (!$http_request && empty($cover_data)) { + return $covers; + } + + foreach ($cover_data as $cover_info) { // Determine if the local id is a known negative. if (cache_get('ting_covers:' . $cover_info['local_id'], FALSE)) { break; @@ -81,7 +88,12 @@ function ting_covers_objects() { } // Return all image information. - drupal_json_output($covers); + if ($http_request) { + drupal_json_output($covers); + } + else { + return $covers; + } } /**