Far future is not needed in advagg as each file is unique. Also interferes with generation for some reason.

Comments

mikeytown2’s picture

What I have so far


/**
 * Implements hook_file_url_alter().
 */
function advagg_file_url_alter(&$original_uri) {
  // Do nothing if
  //  in maintenance_mode
  //  CDN far future is disabled
  //  CDN mode is not basic
  //  URI does not contain /advagg_
  if (   variable_get('maintenance_mode', FALSE)
      || !module_exists('cdn')
      || !variable_get(CDN_BASIC_FARFUTURE_VARIABLE, CDN_BASIC_FARFUTURE_DEFAULT)
      || variable_get(CDN_MODE_VARIABLE, CDN_MODE_BASIC) != CDN_MODE_BASIC
      || strpos($original_uri, '/advagg_') === FALSE
      || strpos($original_uri, 'cdn/farfuture/') === FALSE
        ) {
    return;
  }

  $filename = basename($original_uri);
  //  Do nothing if filename has the wrong pattern.
  if (!preg_match('/^(j|cs)s' . ADVAGG_SPACE . '[A-Za-z0-9-_]{43}' . ADVAGG_SPACE . '[A-Za-z0-9-_]{43}' . ADVAGG_SPACE . '[A-Za-z0-9-_]{43}\.(j|cs)s$/', $filename)) {
    return;
  }

  $start = strpos($original_uri, 'cdn/farfuture/');
  $sub = substr($original_uri, $start+14);
  $x = strpos($sub, '/');
  $sub = substr($sub, $x+1);
  $x = strpos($sub, '/');
  $sub = substr($sub, $x+1);
  $original_uri = substr($original_uri, 0, $start) . $sub;
}

Last bit needs a lot more comments, it appears to work.

mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new1.54 KB
mikeytown2’s picture

Following patch has been committed as well

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.