/** * Accepts AJAX request containing list of IDs to be generated and returned. * Returns associative array mapping ID to thumbnail URL for all icons that were generated, * skipping any that could not be processed. */ public static function generateIcons() { $ret = array(); if (isset($_REQUEST['ids'])) { foreach ($_REQUEST['ids'] as $id) { // only return URL if different from default -- default image is already displayed on the client side $url = DG_Thumber::getInstance()->getThumbnail($id, 1, true, $is_default); if (!$is_default) { $ret[$id] = $url; } } } wp_send_json($ret); }
/** * * @param int $ID The attachment ID. * @param int $pg The page number to use (1-based numbering). * @param bool $generate_if_missing Whether to generate the thumbnail if it has not yet been generated. * * @return string The URL for the thumbnail NULL. Note that if generate_if_missing * is true then you will never get NULL -- you will get a default icon if generation fails. */ public static function getThumbnail($ID, $pg = 1, $generate_if_missing = false) { include_once DG_PATH . 'inc/class-thumber.php'; return DG_Thumber::getInstance()->getThumbnail($ID, $pg, $generate_if_missing); }