示例#1
0
  /**
   * wp_load_image() - Load an image which PHP Supports.
   *
   * @package WordPress
   * @internal Missing Long Description
   * @param string $file Filename of the image to load
   * @return resource The resulting image resource on success, Error string on failure.
   */
  public Object wp_load_image(Object fileObj) {
    int image = 0;

    // Modified by Numiton
    String file;

    if (is_numeric(fileObj)) {
      file =
          strval(
              getIncluded(PostPage.class, gVars, gConsts)
                  .get_attached_file(intval(fileObj), false));
    } else {
      file = strval(fileObj);
    }

    if (!FileSystemOrSocket.file_exists(gVars.webEnv, file)) {
      return QStrings.sprintf(
          getIncluded(L10nPage.class, gVars, gConsts).__("File \'%s\' doesn\'t exist?", "default"),
          file);
    }

    if (!true) /*Modified by Numiton*/ {
      return getIncluded(L10nPage.class, gVars, gConsts)
          .__("The GD image library is not installed.", "default");
    }

    // Set artificially high because GD uses uncompressed images in memory
    Options.ini_set(gVars.webEnv, "memory_limit", "256M");
    image =
        Image.imagecreatefromstring(
            gVars.webEnv, FileSystemOrSocket.file_get_contents(gVars.webEnv, file));

    if (!is_resource(image)) {
      return QStrings.sprintf(
          getIncluded(L10nPage.class, gVars, gConsts).__("File \'%s\' is not an image.", "default"),
          file);
    }

    return image;
  }