You are here

function shrinktheweb_getThumbnail in ShrinkTheWeb 8

Same name and namespace in other branches
  1. 6 shrinktheweb.api.inc \shrinktheweb_getThumbnail()
  2. 7 shrinktheweb.api.inc \shrinktheweb_getThumbnail()

Gets the thumbnail for the specified website, stores it in the cache, and then returns the relative path to the cached image.

Parameters

$sUrl:

$aOptions:

Return value

bool|string

2 calls to shrinktheweb_getThumbnail()
shrinktheweb_getThumbnailAdvanced in ./shrinktheweb.api.inc
Getting the thumbnail with advanced api. !!! SLIGHTLY CHANGED FOR DRUPAL !!!
shrinktheweb_refreshThumbnail in ./shrinktheweb.api.inc
Refresh a thumbnail for a url with specified options. First delete it and then do a new request and return the HTML for image loading. !!! SLIGHTLY CHANGED FOR DRUPAL !!!

File

./shrinktheweb.api.inc, line 152

Code

function shrinktheweb_getThumbnail($sUrl, $aOptions) {

  // Create cache directory if it doesn't exist.
  shrinktheweb_createCacheDirectory();
  $aArgs = shrinktheweb_generateRequestArgs($aOptions);

  // Try to grab the thumbnail.
  $iCacheDays = CACHE_DAYS + 0;
  if ($iCacheDays >= 0 && $aOptions['Embedded'] != 1) {
    $aArgs['stwurl'] = $sUrl;
    $sImageUrl = shrinktheweb_getCachedThumbnail($aArgs);
  }
  else {

    // Do NOT trigger notify callback on embedded!
    unset($aArgs['stwcallback']);

    // ONLY on "Advanced" method requests!! (not allowed on embedded).
    unset($aArgs['stwu']);
    $aArgs['stwembed'] = 1;

    // MUST come last, since we haven't been urlencoding URL
    $aArgs['stwurl'] = $sUrl;
    if ($aOptions['RefreshOnDemand']) {
      $sRequestUrl = PROTOCOL . 'images.shrinktheweb.com/xino.php';
      shrinktheweb_fileGetContent($sRequestUrl, $aArgs);
    }
    else {

      // Get raw image data.
      $sImageUrl = urldecode(PROTOCOL . 'images.shrinktheweb.com/xino.php?' . http_build_query($aArgs, '', '&'));
    }
  }
  return $sImageUrl;
}