public function __construct($src, $type, $alt = '') { $this->src = (string) $src; $this->type = (string) $type; $this->alt = empty($alt) ? array_shift(explode('?', basename($this->src))) : (string) $alt; // remove ?x=.. part from basename }