- $enclosure->title=$this->title;
- $enclosure->url=$this->url;
- $enclosure->title=$this->title;
- $enclosure->date=$this->date;
- $enclosure->modified=$this->modified;
- $enclosure->size=$this->size;
- $enclosure->mimetype=$this->mimetype;
-
- if(! isset($this->filename)){
- $notEnclosureMimeTypes = array(null,'text/html','application/xhtml+xml');
- $mimetype = $this->mimetype;
- if($mimetype != null){
- $mimetype = strtolower($this->mimetype);
- }
- $semicolon = strpos($mimetype,';');
- if($semicolon){
- $mimetype = substr($mimetype,0,$semicolon);
- }
- if(in_array($mimetype,$notEnclosureMimeTypes)){
- // Never treat generic HTML links as an enclosure type!
- // But if we have oEmbed info, we'll consider it golden.
- $oembed = File_oembed::getKV('file_id',$this->id);
- if($oembed && in_array($oembed->type, array('photo', 'video'))){
- $mimetype = strtolower($oembed->mimetype);
- $semicolon = strpos($mimetype,';');
- if($semicolon){
- $mimetype = substr($mimetype,0,$semicolon);
- }
- // @fixme uncertain if this is right.
- // we want to expose things like YouTube videos as
- // viewable attachments, but don't expose them as
- // downloadable enclosures.....?
- //if (in_array($mimetype, $notEnclosureMimeTypes)) {
- // return false;
- //} else {
- if($oembed->mimetype) $enclosure->mimetype=$oembed->mimetype;
- if($oembed->url) $enclosure->url=$oembed->url;
- if($oembed->title) $enclosure->title=$oembed->title;
- if($oembed->modified) $enclosure->modified=$oembed->modified;
- unset($oembed->size);
- //}
- } else {
- return false;
- }
- }