我刚遇到这个问题,不得不编写代码来处理这个问题。
这有效地克隆theme_image_style()以在执行页面请求期间创建图像派生类。生成会绕过通常会触发404的安全问题,但这也意味着第一次访问该页面时页面会变慢。
我仅使用公共文件架构,但是我期望基于私有文件架构的样式会失败。
    /**
     * Implements hook_theme().
     */
    function MODULE_theme() {
      return array(
        'remote_image_style' => array(
          'variables' => array(
            'style_name' => NULL,
            'path' => NULL,
            'width' => NULL,
            'height' => NULL,
            'alt' => '',
            'title' => NULL,
            'attributes' => array(),
          ),
        ),
      );
    }
    /**
     * Returns HTML for an image using a specific image style.
     *
     * Clones theme_image_style() with the additional step of forcing the creation
     * of the derivative to bypass any 404 issues.
     */
    function theme_remote_image_style($variables) {
      // Determine the dimensions of the styled image.
      $dimensions = array(
        'width' => $variables['width'],
        'height' => $variables['height'],
      );
      image_style_transform_dimensions($variables['style_name'], $dimensions);
      $variables['width'] = $dimensions['width'];
      $variables['height'] = $dimensions['height'];
      $image_style_dest_path = image_style_path($variables['style_name'], $variables['path']);
      if (!file_exists($image_style_dest_path)) {
        $style = image_style_load($variables['style_name']);
        image_style_create_derivative($style, $variables['path'], $image_style_dest_path);
      }
      $variables['path'] = file_create_url($image_style_dest_path);
      return theme('image', $variables);
    }