diff options
Diffstat (limited to 'class/class.w.media.php')
-rw-r--r-- | class/class.w.media.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/class/class.w.media.php b/class/class.w.media.php index e5056c9..2d27be7 100644 --- a/class/class.w.media.php +++ b/class/class.w.media.php @@ -9,6 +9,11 @@ class Media private $size; private $width; private $height; + private $length; + + const IMAGE = array('jpg', 'jpeg', 'gif', 'png'); + const SOUND = array('mp3', 'flac'); + const VIDEO = array('mp4', 'mov', 'avi'); @@ -31,6 +36,24 @@ class Media } + public function analyse() + { + $this->settype(); + + $filepath = $this->path . $this->id . '.' . $this->extension; + + $this->size = filesize($filepath); + + if ($this->type == 'image') { + list($width, $height, $type, $attr) = getimagesize($filepath); + $this->width = $width; + $this->height = $height; + } + + + } + + // _________________________________________________ G E T ____________________________________________________ @@ -69,6 +92,11 @@ class Media return $this->height; } + public function length() + { + return $this->length; + } + // ___________________________________________________ S E T __________________________________________________ public function setid($id) @@ -92,6 +120,21 @@ class Media } } + public function settype() + { + if (isset($this->extension)) { + if (in_array($this->extension, $this::IMAGE)) { + $this->type = "image"; + } elseif (in_array($this->extension, $this::SOUND)) { + $this->type = "sound"; + } elseif (in_array($this->extension, $this::VIDEO)) { + $this->type = "video"; + } else { + $this->type = "other"; + } + } + } + public function setsize($size) { if (40 and is_int($size)) { @@ -113,6 +156,14 @@ class Media } } + public function setlength($length) + { + if ($this->type == 'sound') { + $this->length = $length; + } + } + + |