ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMediaImageUtil Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilMediaImageUtil:

Static Public Member Functions

static getImageSize (string $a_location)
 Get image size from location. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Image utility class

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilMediaImageUtil.php.

Member Function Documentation

◆ getImageSize()

static ilMediaImageUtil::getImageSize ( string  $a_location)
static

Get image size from location.

Exceptions
ilCurlConnectionException

Definition at line 30 of file class.ilMediaImageUtil.php.

References $c, Vendor\Package\$e, $filename, ilCurlConnection\_isCurlExtensionLoaded(), ilFileUtils\getDataDir(), and ilFileUtils\makeDirParents().

Referenced by ilObjMediaObject\_determineWidthHeight(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObjectGUI\getFullscreenSizeObject(), ilMediaItem\getOriginalSize(), ilObjMediaObjectGUI\getStandardSizeObject(), and ilObjMediaObject\makeThumbnail().

30  : ?array
31  {
32  if (substr($a_location, 0, 4) == "http") {
34  $dir = ilFileUtils::getDataDir() . "/temp/mob/remote_img";
36  $filename = $dir . "/" . uniqid();
37  $file = fopen($filename, "w");
38  $c = new ilCurlConnection($a_location);
39  $c->init();
40  $c->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
41  $c->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
42  $c->setOpt(CURLOPT_MAXREDIRS, 3);
43  $c->setOpt(CURLOPT_HEADER, 0);
44  $c->setOpt(CURLOPT_RETURNTRANSFER, 1);
45  $c->setOpt(CURLOPT_FILE, $file);
46  try {
47  $c->exec();
48  $size = getimagesize($filename);
49  } catch (ilCurlConnectionException $e) {
50  $size = null;
51  }
52  $c->close();
53  fclose($file);
54  unlink($filename);
55  } else {
56  $size = getimagesize($a_location);
57  }
58  } else {
59  if (is_file($a_location)) {
60  $size = getimagesize($a_location);
61  }
62  }
63  if (!isset($size) || $size === false) {
64  $size = [0,0];
65  }
66  return $size;
67  }
$c
Definition: cli.php:38
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getDataDir()
get data directory (outside webspace)
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: